I've already asked about installing python packages at $HOME. It worked flawlessly.
Now, I'm planning to install Vagrant. It's a gem (a ruby package), and I would like to install it in my $HOME folder as well but I'm not used to it so I'm asking for help here.
I've already run,
sudo gem update --system
As followed by their mac tutorial. And when I try to install Vagrant using their recomendation:
gem install vagrant
I get:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/bin directory.
(It's strange that just gem install vagrant
doesn't work, I followed the guide from Vagrant's official website in a vanilla installed Mac, never used Ruby here and I got the error. Specially when using sudo is not required.)
Ok. Using sudo is going to resolve it, but I don't want to install this gem system wide, I want to install them at $HOME like I did with pip - and I have no idea how I can do it without messing up with this mac machine. Can someone help me how to do it the best way? Which variables to I have to export, if I have to add ~/.gem
to my $PATH
, or something like that. (Did I already messed everything up when I used sudo gem update --system
?)
Some people are suggesting to use rvm, but I think this is overkill since I'm not going to develop ruby applications against the system Ruby, I just want to run Vagrant. Of course, if there isn't another way, I'm going to use it.
My gem environment command outputs:
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/user/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
EDIT: I've found a tutorial, that says that I need just to add to my .profile
:
export GEM_HOME=$HOME/.gems
export PATH=$GEM_HOME/bin:$PATH
Is it safe to use this approach?