How to install gems without sudo on Mac OS X
I have read numerous posts but no one has done this so far.
How can I, on OSX (El Capitan Beta), install a gem for my own user? The posts suggest to mention -user-install
for example, but I can't call gem
without sudo
at all as it throws permission errors.
I followed " install gem as user on OSX 10.10 Yosemite " but still can't make a call gem
.
I installed Homebrew, installed rbenv according to the guide above, installed the Ruby version with rbenv, verified that it loaded correctly, but the last step in the guide is to invoke gem install
, which I still cannot do.
The gem
post-installation call rbenv
results in:
/Users/Me/.rbenv/versions/2.1.5/lib/ruby/2.1.0/rubygems/stub_specification.rb:71:in `initialize':
Permission denied @ rb_sysopen - /Users/Ne/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/speci
rbenv env dump:
RBENV_VERSION=2.1.5 RBENV_ROOT=/Users/Me/.rbenv RBENV_HOOK_PATH=:/Users/Me/.rbenv/rbenv.d: /usr/local/etc/rbenv.d: /etc/rbenv.d: /usr/lib/rbenv/hooks PATH=/Users/Me/.rbenv/versions/2.1.5/bin: /usr/local/Cellar/rbenv/0.4.0/libexec: /Users/Me/.rbenv/plugins/rbenv-env/bin: /Users/Me/.rbenv/shims: /usr/local/heroku/bin: /usr/local/sbin: /usr/local/bin: /usr/local/share/npm/bin: /Applications/Atom.app/Contents/Resources/app/apm/bin: /Users/Me/.bin: /Applications/Atom.app/Contents/Resources/app/apm/node_modules/atom-package-manager/bin: /usr/local/bin:/usr/bin: /bin: /usr/sbin:/sbin: /opt/X11/bin: /usr/local/MacGPG2/bin RBENV_DIR=/Users/Me/.rbenv/plugins
" brew and gem both throw an" Allow denied "error whenever I run it " seems to be related, although it hasn't been resolved other than with another method I might have to do.
source to share
If you can't use gem
without sudo
, it sounds like you've initialized rbenv incorrectly because shims aren't available.
These steps are taken from the documentation . Confirm that you have done EVERYTHING:
Add ~ / .rbenv / bin to your $ PATH to access the rbenv command line utility.
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
Ubuntu Desktop Note: Change your ~ / .bashrc instead of ~ / .bash_profile.
Zsh Note: Change ~ / .zshrc file instead of ~ / .bash_profile.
Add rbenv init to your shell to enable shims and autocomplete.
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
As in the previous step, use ~ / .bashrc for Ubuntu or ~ / .zshrc for Zsh.
Restart the shell for the PATH changes to take effect. (Usually open a new terminal tab.) Now check if rbenv is configured:
$ type rbenv
#=> "rbenv is a function"
source to share