How do I fix the "You don't have write permissions into the /usr/bin directory" error when installing Rails?

ID : 20046

viewed : 8

Tags : ruby-on-rails-3ruby-on-rails-3

Top 5 Answer for How do I fix the "You don't have write permissions into the /usr/bin directory" error when installing Rails?

vote vote

96

use -n parameter to install like for cocoapods:

sudo gem install cocoapods -n /usr/local/bin 
vote vote

87

Using the -n /usr/local/bin flag does work, BUT I had to come back to this page every time I wanted to update a package again. So I figured out a permanent fix for this.

For those interested in fixing this permanently:

Create a ~/.gemrc file

vim .gemrc 

With the following content:

:gemdir:    - ~/.gem/ruby install: -n /usr/local/bin 

Now you can run your command normally without the -n flag.

Enjoy!

vote vote

73

sudo gem install cocoapods --pre -n /usr/local/bin 

This works for me.

vote vote

60

You can use sudo gem install -n /usr/local/bin cocoapods

This works for me.

vote vote

59

I'd suggest using RVM it allows you have multiple versions of Ruby/Rails installed with gem profiles and basically keep all your gems contained from one another. You may want to check out a similar post How can I install Ruby on Rails 3 on OSX

Top 3 video Explaining How do I fix the "You don't have write permissions into the /usr/bin directory" error when installing Rails?

Related QUESTION?