RVM - Two projects pointing to same non-universal Rails version


Say I have a project directory Ann, which has rails 4.1 installed. In directory Bob I have have rails 4.2 installed. Now I want to install rails 4.2 in directory Cas. I don’t want to have a universal rails 4.2 because then when I enter project Ann I have to remember to use 4.1, and when I enter project Bob I don’t want to have to switch to rails 4.2.

However, I also don’t want to install Rails 4.2 AGAIN for Cas. I want Cas to point to whatever Rails Bob is using and for them to share it. Or I want a Rails 4.2 in another directory that they can both point to.

Is this possible?

-thanks Flo

Normally you don’t need to add Rails itself to the project, you just reference the version you want to use in the project’s Gemfile.

As long as you prefix any Rails command command with bundle exec then the correct version should be used.

Hi andyw8, thanks for your prompt reply.

Well, I think normally I do need to have rails installed, since normally I use ‘rails new project_name’ to create a new project which provides me with the gemfile. That is the rails I’m talking about. Is there any way that every time I enter a directory I would be using a particular version of rails for my rails commands without having to ask rvm to use “particular version”. I just would like it to be automatic, and to not have to install that particular version in every project directory that I want it to be used in. Is this possible? If not, that’s okay, I’m starting to think it’s not possible.

Do you think that is an odd request because the bundler is going to install a version of rails as directed by my gemfile? I think the rails that is bundled is different from the one I use in my command line.

Also, typing bundle exec before every command does not seem normal to me. I don’t think that is the normal way of things. I mean maybe it is, but since RVM came out I don’t think that it is.


Ok, I think I understand what you mean, you want to decide when creating a new app, whether to use Rails 4.1 or 4.2?

I can’t say I’ve ever needed to do this. Whenever I’m creating a new app, I always want to use the latest release of Rails.

What are the circumstances that necessitate using an older version of Rails?

True, I don’t have a situation right now, but am worried because I had a situation when moving from rails 3 to rails 4. My scenario above doesn’t involve installing outdated rails, it does have Project Ann using 4.1 indefinitely, while making new projects with 4.2.

Basically, say I have a parent directory where I have rails 4.2 installed.
Then inside parent directory I create a new project ‘A’ it’s command line would be in rails 4.2.

Then later rails 5.0 comes out, I would install rails 5.0 in parent directory, so that I could call
’rails new projectB’. Then my project B would be in rails 5.0.

I had a similar situation when rails switched from rails 3.0 to 4.0. I had project C using 3.2 and project D using 4.0. When I went into project C I would type ‘rvm use ruby1.9@rails3’ (or something similar), then when I went into project D I would ‘rvm use ruby2.0@rails4’. Always having to switch gemsets when I entered the different project directory.
The way I have things set up now, I’m going to run into the same situation. That’s why I’m asking because remembering which gemset to use on which project is a pain.
I imagine that I could have a parent directory with projects inside of it, and each project would have its own install of rails. So Project D would have rails 5.0 installed. Then Project E also uses rails 5.0, so install rails 5.0 in Project E. Then Project F would install 6.0, then Project G would install 6.0 also. All the different installs seem wasteful.

Is that the way it’s done, remembering which gemset to use when you’re in a particular project? I agree, I haven’t used rails in a long time and never became proficient, but hoping you could help.

I’m still hoping there is some way to make the directory remember which rails version to use when I run rails commands.

Thanks for all your time. You’re very nice.


If you want to tell me to run some more tests first and make some git repository to look at that’s fine too. Just had some rails segmentation fault I fixed (stumbled upon answer) so now I could come up with some way to better illustrate my question.

RVM does have a feature where you can tell it which gemset to use by creating a .ruby-gemset file in the directory:


Personally I find it unnecessary, but if you’re more comfortable working this way then give it a try.

Great! I’m going to try that.

-flo (aka happy camper)