简体   繁体   中英

'gem install' and 'sudo gem install'

I've got an issue installing gems on my mac (os 10.6).

I used to be able to run

gem install <gem-name-here>

but after updating something , it could be the version of gem I'm using, but it's unlikely, I now get the error:

ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/bin directory.

On the face of it, it looks like my 'GEM_HOME' isn't set. If so, why has this been unset, and how can I change it back?

Secondly - when I run

gem list

I see all gems - including those in ~/.gem, but when I run:

gem server

I only see gems in /usr/bin... strange huh?

Any help would be great to resolve this - I dont like using sudo to install gems constantly.

  1. Install RVM .
  2. Profit!

It really is that simple. In addition, you will be able to install and easily switch between different Ruby versions and sets of gems with a single command. It will all be installed in ~/.rvm (by default) and you won't need to use sudo to install gems.

Follow the instructions in this guide :

export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH

gem install <gem-name-here>

If you were already doing this, completely delete the ~/.gem directory and try again.

在安装所需的gem之后,您是否尝试过进行$bundle update

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM