Buzbe
Buzbe

Reputation: 99

'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.

Upvotes: 1

Views: 1961

Answers (3)

Iulian Onofrei
Iulian Onofrei

Reputation: 9740

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.

Upvotes: 0

uday
uday

Reputation: 8730

Have you tried doing $bundle update after installing the gems that you wanted?

Upvotes: 0

Lars Haugseth
Lars Haugseth

Reputation: 14881

  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.

Upvotes: 7

Related Questions