0

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!

engineersmnky
  • 25,495
  • 2
  • 36
  • 52
HFarias_
  • 1
  • 1

1 Answers1

1

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.

Allison
  • 1,925
  • 1
  • 18
  • 25
  • "...choose a different project." Is the better part of this advice since rails 5.2 falls out of support at the end of May 2022. – engineersmnky Feb 12 '22 at 04:30
  • @engineersmnky Yes that is why I added that recommendation, as the terrible logic in that case statement alone would send me running. But I've had the benefit of a formal CS education, whereas people who ask very early learning questions like this tend to be new students with little-to-no support who have some investment in completing a badly aging tutorial. It's that dude's first SO post; if this is what he's using as his launching point to learn, let him. – Allison Feb 12 '22 at 04:54