I am exploring the world of Ruby and RVM. I am going through a lot of documentation and trying out RVM, but I am a bit confused about the entire work flow. I am writing down the workflow as I understand it. Can someone please take a look and see if this understanding is correct?
I am using a Mac.
- RVM is essentially a script that allows us to manage Ruby environments for development purposes.
- RVM allows switching between different versions of Ruby with
rvm use 1.9.2. - To use a particular gemset with the current Ruby version, we need to create a gemset using
rvm --create gemset rails235 - Install the gem using
gem install rails -v=2.3.5
Q: What happens if I did
gem install rails -v=2.3.5prior to creating a gemset? Will there be two copies of the same Rails installed under RVM’s Ruby 1.9.2?Q: What happens if I install 2.3.5 and 3.1.0 prior to creating gemsets and then create a gemset for each version?
Q: where does
rvmrccome into picture in the whole story?
Any other information that helps me get this straight is extremely helpful.
@Kiran, this is in reference to your comment above. When you install a different version of ruby with rvm, it’ll add to this list:
On my system, I’ve only got one version running (for now). This helps too
The practice is to install common gems into your
globalgemset and create/use sets for everything else. I tend to keeppryand others in the global gemset. As Mike K. said, you’d never do #2; if you did do such a thing, I would imagineglobalhaving priority.#3 .rvmrc
You can do things like this in the file:
This will ensure whenever you ‘cd’ into the directory, it’ll switch to 1.9.2 and it’s ‘rails3’ gemset; the following attribute ensures the gemset will be created if it doesn’t already exist.
Update
That’s easy – when you run
bundle installit creates aGemfile.lock; this essentially ‘locks’ the gems that your application is set to use. You’ve never require two different versions of rails in a singleGemfileanyways – that’s just ridiculous =)