I\'m building a vagrant setup, and part of that is installing rbenv. I\'m using librarian-chef to manage all my chef cookbooks, and it installs rbenv and ruby-build.
How
Everything in rbenv's Readme is assume a local (per-user) installation in ~/.rbenv/
so i would assume that the official recommendation is to install it on a per-user basis.
Still, it's possible to install it globally. But you'll need sudo
for all commands that need to writing rights. Installing new rubies, installing gems* and changing the global ruby version are the ones coming to my mind here, there might be more.
(*) Needing sudo for installing new gems is the default when you install your ruby through the default system routines like apt on debian, not needing sudo for it is actually a positive side effect of using ruby version managers that work on a per-user basis
rbenv should be installed at a user level.
Unfortunately, this means that when running gem install
, you may run into the problem you saw:
You don't have write permissions into the {...} directory
You can solve this by setting the correct permissions on the ~/.rbenv
directory.
sudo chown -R yourusername ~/.rbenv
After chown
ing the directory, you'll be able to run gem install
without sudo
.
About two years ago, a discussion happened in github about shared installs, which appears to answer the question.
Synopsis: sstephenson (rbenv author) specifically doesn't like encouraging system-wide installs because of complexities with permissions, write access, etc. He believes adding robust support would make rbenv more complex, and simplicity is the goal.
EDIT
I've since come across fnichol's chef-rbenv cookbook, which, if you actually want to install a system-wide rbenv, gives a right and proper method, and you can automate it with Chef (I recommend knife solo).
It installs this to /etc/profile.d/
so it will run for all users, putting the proper ruby into the PATH.