0

Thank you this community for getting me started on the right path. Specifying rails version to use when creating a new application gets me close, but the differing ruby version is what is throwing me off. I'm running into an error after running rails new that I'm not sure where to begin to resolve it. I gather from the error that my command is missing a parameter, but I can't determine what it is.

Any advice?

I would like to create a rails 5.2.6 project and I'm finding consistent responses elsewhere indicating that my approach to getting a rails project created with a specific version is to: install the rails gem with gem install rails -v 5.2.6 create a new rails project, specifying the rails version with rails _5.2.6 new appName

I think I'm on to it. Did a specific google search for compatibility of Ruby 3 with Rails 5 and appears this is the likely problem.

I've now run 'rvm install 2.7.4' then 'rvm use 2.7.4' but still seems to be using ruby 3 in the command. The new error:

user@ubuntudev:~/railsprojects$ rails _5.2.6_ new rpapitest
/home/user/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems.rb:281:in `find_spec_for_exe': can't find gem railties (= 5.2.6) with executable rails (Gem::GemNotFoundException)
    from /home/user/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems.rb:300:in `activate_bin_path'
    from /home/user/.rbenv/versions/3.0.0/bin/rails:23:in `<main>'
Stefan
  • 3
  • 2
  • You need to switch to other ruby version `rvm use 2.7.4`. Switching to other ruby version will require you to install rails again with `gem install rails -v 5.2.6` and then `rails new` should work – BroiSatse Oct 26 '21 at 15:34
  • Hmm. I definitely don't yet understand the role of rvm vs rbenv, but with your prompt, I know also have rvm installed version and using 2.7.2 in line with rbenv. same 'rails' command error so far. Still digging but thank you for the additional pointer. – Stefan Oct 26 '21 at 15:46
  • Oh no, you have both rbenv and rvm! This will not play nicely! You need to make a decision and remove one of them - they both to the same thing and they will fight with each other. I've personally been using RVM since I remember, but there's really not much difference AFAIK – BroiSatse Oct 26 '21 at 15:52
  • Well then.... I'm going to scrub this install and start from scratch. Thank you BroiSatse. – Stefan Oct 26 '21 at 15:54

1 Answers1

-1

Try with rbenv global 2.7.4 if you have rbenv installed

Stéphane
  • 34
  • 5
  • I think this got me closer. I needed to rbenv install 2.7.2 (2.7.4 wasn't available), then rbenv global 2.7.2, then tried 'rails new' command, but errors out with: "The 'rails' command exists in these Ruby versions: 3.0.0" Figuring i need to install rails, but fails on "failed to build gem native extension". Thank you for getting me closer! – Stefan Oct 26 '21 at 15:35