Try upgrading your installation of RVM if you are running something older than 1.6.10 (check your active version with rvm --version
).
In some shell:
rvm get latest
Then, either restart your other, existing shells, or run rvm reload
in them.
Note: Another problem the OP faced was PATH manipulation after RVM was loaded into the shell. This created the “right gemset selected, but wrong installation of ruby” effect that disappeared after “cd out, cd in” (since RVM would have reasserted its position in the PATH at that point). When a shell is started in a directory that contains an .rvmrc
it is vital that RVM be the last thing to prepend elements to the PATH (at least any PATH elements that might contain a ruby
(etc.) so that the Ruby installation selected in the .rvmrc
will be effective).
RVM arranges to source .rvmrc
files by “hooking” your shell’s cd
command (a cd
shell function in bash, an entry in chpwd_functions
for zsh). Normally this lets it catch any “normal” cd
command that you type it or run via a sourced script after loading RVM.
I do not have Lion to test with, but I suspect the way it works is that Terminal forks, calls chdir(2), then execs your shell to establish your new shell’s initial working directory. This means that the directory is already established by the time RVM is loaded in your shell initialization file.
The history seems a bit muddy, but RVM has had some support for sourcing the .rvmrc
file in the shell’s initial working directory when it is first loaded. It looks like maybe it was intended to be screen-specific, but in RVM commit cb649ba (Always load the .rvmrc if in an interactive shell (open new tab in same dir)., 2011-05-14) relaxed the requirement so that it should source .rvmrc
files for any interactive shell when RVM is first loaded. This commit was first present in the 1.6.10 release of RVM. The code has changed a bit since then, but it still works in (more or less) the same way in the latest versions.
Best Answer
You should use RVM, the Ruby Version Manager. It allows multiple side-by-side installations of Ruby without affecting the system Ruby installation, which as another commenter pointed out can potentially be problematic (or at the very least, tiresome to maintain).
It allows you to quickly and easily install the latest patchlevel of Ruby, past Ruby versions, or even alternate implementations like JRuby, MacRuby, or Rubinius.
To install:
Once it's installed, setting 1.9.2 as the default is as simple as typing:
And if you feel like switching back to 1.8.7 temporarily: