Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 1347 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to install a gem or update RubyGems if it fails with a permissions error

#11
**Installing gem or updating RubyGems fails with permissions error Then Type This Command**

sudo gem install cocoapods
Reply

#12
I found [this how-to for `sudo`less gem][1]:

1. `brew install rbenv ruby-build`
2. `sudo gem update --system`
3. add exports to `.bashrc`:

<!-- language: lang-sh -->

export RBENV_ROOT="$(brew --prefix rbenv)"
export GEM_HOME="$(brew --prefix)/opt/gems"
export GEM_PATH="$(brew --prefix)/opt/gems"

4. And finally add this to your `~/.gemrc`:

gem: -n/usr/local/bin

5. `gem update --system`

[1]:

[To see links please register here]

Reply

#13
You really should be using a Ruby version manager.

Using one properly would prevent and can resolve your permission problem when executing a `gem update` command.

I recommend *rbenv*.

However, even when you use a Ruby version manager, you may still get that same error message.

If you do, and you are using rbenv, just verify that the `~/.rbenv/shims` directory is before the path for the system Ruby.

`$ echo $PATH` will show you the order of your load path.

If you find that your shims directory comes after your system Ruby bin directory, then edit your `~/.bashrc` file and put this as your last export PATH command: `export PATH=$HOME/.rbenv/shims:$PATH`

`$ ruby -v` shows you what version of Ruby you are using

This shows that I'm currently using the system version of Ruby (usually not good)

$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

`$ rbenv global 1.9.3-p448` switches me to a newer, pre-installed version (see references below).

This shows that I'm using a newer version of Ruby (that likely won't cause the Gem::FilePermissionError)

$ ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]


You typically should not need to preface a gem command with sudo. If you feel the need to do so, something is probably misconfigured.

For details about rbenv see the following:

*

[To see links please register here]

*

[To see links please register here]

Reply

#14
There are two routes: Use either rbenv or RVM. There are recipes for both below. Before you do, you probably want to turn off the installation of local documents for gems.

echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

Then:

[`install rbenv` ](

[To see links please register here]

)

[`install ruby-build`](

[To see links please register here]

)

run:

rbenv install 2.1.2 (or whatever version you prefer)
rbenv global 2.1.2
gem update --system

This installs an up-to-date version of the gem system in your local directories. That means you don't interfere with the system configuration. If you're asking this question, you shouldn't be messing with system security, and you'll spend longer understanding what issues you may run into, than just having an easy way to avoid the problem you started with. Learn InfoSec later, when you know more about the operating system and programming.

For an alternative use 'RVM' instead: To [install rvm](

[To see links please register here]

) run:

rvm install 2.1.2
rvm use 2.1.2
gem update --system

This has the same result, you end up with a local Ruby and Gem system that doesn't interfere with the system versions. There is no need for Homebrew, or over-riding system libs, etc.
Reply

#15
This worked for me. Plus, if you installed gems as root before, it fixes that problem by changing ownership back to you (better security-wise).

sudo chown -R `whoami` /Library/Ruby/Gems

Reply

#16
Check to see if your Ruby version is right. If not, change it.

This works for me:

$ rbenv global 1.9.3-p547
$ gem update --system
Reply

#17
I had formatted my Mac and many suggested solutions did not work for me.
What worked for me are these commands in the correct order:


1. Install Homebrew:

/usr/bin/ruby -e "$(curl -fsSL

[To see links please register here]

;

2. Install Ruby:

brew install ruby

3. Install Compass:

sudo gem install compass
Reply

#18
Try adding `--user-install` instead of using `sudo`:

gem install mygem --user-install
Reply

#19
You can use: gem install cocoapods --pre --user
Reply

#20
Install rbenv by `brew install rbenv`;

Then put `eval "$(rbenv init -)"` at the end of ~/.bash_profile (or ~/.zshrc
of MacOS);

Open a new terminal and run `gem install ***` will work!
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through