0

I want to upgrade an application to the latest Rails version (4.2).

I'm using rbenv as a version manager.

Can I just install the rails 4.2 gem without affecting my other Rails applications?

thanks for your advice,

Anthony

Toontje
  • 1,415
  • 4
  • 25
  • 43

1 Answers1

0

rbenv is a tool for managing different ruby versions in your system. While it's possible to install different rails versions for a single ruby version installed using rbenv, installing rails is bundler's job.

Quoting from a really good answer by Nathan from here, where it's explained how would one install different rails versions for a single ruby version (go and upvote the answer if you find this helpful) :

So once you get rbenv installed, and you use it to install a specific ruby version, you can install multiple versions of rails to for that ruby.

STEP 1. Install whatever version(s) of rails you want per ruby version

% RBENV_VERSION=1.9.2-p290 rbenv exec gem install rails --version 3.0.11

By using the "RBENV_VERSION=1.9.2-p290" prefix in your command line, you're specifying which ruby rbenv should be concerned with.

Then following that with the "rbenv exec" command, you can install rails. Just use the version flag as in the example to specify which version you want. Not sure if you can install multiple versions in one shot, but I just run this command as many times as needed to install each version I want.

Note: This will all be managed within your rbenv directory, so it's perfectly safe and contained.

STEP 2. Build a new rails project by specifying the rails version you want.

% RBENV_VERSION=1.9.2-p290 rbenv exec rails _3.0.11_ new my_project

STEP 3. Don't forget to go into that project and set the local rbenv ruby version.

% cd my_project % rbenv local 1.9.2-p290

And here is Michael's blog post explaining how one can manage different rails versions installed this way. You would basically modify the Gemfiles and specify the version you want, and then let bundler take care of installation. Here's the answer where he talks about this.

Also, I haven't tried rbenv-gemset but it looks promising at a glance. I would use it if I were you, at least to try it once. :)

Community
  • 1
  • 1
Bharadwaj Srigiriraju
  • 2,196
  • 4
  • 25
  • 45