Ask A Question

Notifications

You’re not receiving notifications from this thread.

Running multiple Rails versions

Jiri Prochazka asked in Rails

Hi guys (and ladies if any),

I have installed Rails with rbenv (recommended), but now because of significant changes between 5.0.1 and 5.1 versions, I want to start a new project with 5.1 (because I'm going to havily use javascript), but keep also my older projects running on 5.0.1.

And now what? Do I have to smehow uninstall Rails for rbenv and install it for rvm, or can I just "replace" it??

What about the setting of older projects when switching to rvm? Do the projects need to be updatesd somehow (configuration etc.)?

Thanks

Reply

Every Rails project has the version of Rails in the Gemfile that it will use separately from every other app. There's nothing you need to do to manage two different Rails versions.

The only thing you'll want to do is gem install rails to get the latest version and create your new project with rails new myapp. That will make sure the new project starts with Rails 5.1 (or whatever is the latest at the time).

You can also create apps with older versions of rails using rails _4.2.0_ new myapp

Rbenv and Rvm have pretty much nothing to do with this because they are for Ruby versions, not Rails. All of this is taken care of by Bundler.

When you switch apps to work on the correct versions will be automatically used, no changes required by you.

Reply

ok, thanks.
But I have Rails 5.0.1 gem already installed. How can I install the newer gem version withou updating the old one?
Can I run multiple gem versions alongside each other?

Reply

You just run the commands like I said above. All your gems install side by side so you can always have more than one version installed.

Reply

Ok man, cool, thanks!

Reply

Here's why that works, as I understand it: Bundler will take care of ensuring that only the gem versions specified in your Gemfile.lock are in Ruby's library load path.

Reply
Hey guys,

I ran the following command 
rails _5.1.4_ new mynewapp

in the gemfile it says
gem 'rails', '~> 5.1.4'

however, in the gemfile lock it says
rails (5.1.6)
      actioncable (= 5.1.6)
      actionmailer (= 5.1.6)
      actionpack (= 5.1.6)
      actionview (= 5.1.6)
      activejob (= 5.1.6)
      activemodel (= 5.1.6)
      activerecord (= 5.1.6)
      activesupport (= 5.1.6)
      bundler (>= 1.3.0)
      railties (= 5.1.6)
      sprockets-rails (>= 2.0.0)

It doesn't seem right, is it?
Reply
Yep, it's right. The last version number is a patch version for security and bug fixes. You always want the latest version of that.

The first two versions are the ones that change and break things, so those are the ones to worry about being correct.
Reply
I see, thank you Chris
Reply

I am trying to test out the jumpstart rails template. However, I'm running into this issue. Something about different rails versions?

I read the above, but not sure how to fix this. Can anyone assist? Thank you very much.

https://i.gyazo.com/15e8841853fec069447c08b64d040092.png

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.