Ruby on Rails - Composer

119 views Asked by At

i am new to the world of programming and i started programming with ruby ​​on rails on ubuntu 20.4 through virtual machine. I'm trying to make an application with composer. only every time I type: rails new myapplication -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb ; I get the following message: Rails 7.0.2.2 is not supported. Use Rails 4.1 or newer. I installed ruby ​​on rails from rvm and these are my versions:

$ rails -v: Rails 7.0.2.2

$ ruby ​​-v: ruby ​​2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

$ rvm: rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

$ gem list: rails (7.0.2.2, 4.1.0)

I already tried to uninstall this version 7 of rails and install the version that is requested but even so when I create a new application changing the name or overwriting the one I had already created, the same error occurs.

thanks for the help in advance!

1

There are 1 answers

2
Allison On

If you search that composer code, you should find this:

# this application template only supports Rails version 4.1 and newer
case Rails::VERSION::MAJOR.to_s
when "5"
  say_wizard "You are using Rails version #{Rails::VERSION::STRING}. Please report any issues."
when "3"
  say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer."
  raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer."
when "4"
  case Rails::VERSION::MINOR.to_s
  when "0"
    say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer."
    raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer."
  end
else
  say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer."
  raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer."
end

The author did a poor job of writing that case statement and error message. When that case statement runs on your setup, it's doing this:

  1. Is this rails version 5? No? Ok.
  2. Is this rails version 3? No? Ok.
  3. Is this rails version 4? No? Ok.
  4. Well then it must be a rails version before 4, because we all know numbers never grow past 5! ¯\(ツ)

Use RVM to install Rails version 5, or choose a different project.