I think I installed rvm correctly. When I type in rvm -v it outputs
rvm 1.25.33 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
However, I am trying to install the gem rspec. I type in
gem install rspec
but the output is
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
What should I do? What is going wrong? I can't understand the rvm docs either!
Best Answer
RVM controls which Ruby your current shell points to, but it doesn't install a user-controlled Ruby for you by default. If you haven't installed any specific Ruby versions via RVM, the only Ruby you have is the one OS X installed and that requires
sudo
permissions to write to.You can see available Rubies with:
In my case I have 2.1.2 installed and it's both the current Ruby and the default Ruby when I start a new shell:
To install a Ruby version with RVM do:
Now that you have an RVM-managed Ruby installed that's owned by you specifically you can
gem
-install anything you like without needing to usesudo
:That gem has been installed for the 2.1.3 version of Ruby that RVM put under
~/.rvm
for me. If I was to switch to the 2.1.2 version viarvm use ruby-2.1.2
I would not see that gem, I'd have to re-install it to make it available to that Ruby version.You can also manage gems as sets so they're not even shared with a Ruby install. See the gemset basics on the RVM web site for more details.