How do I fix the "You don't have write permissions into the /usr/bin directory" error when installing Rails?
use -n
parameter to install like for cocoapods:
sudo gem install cocoapods -n /usr/local/bin
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!
sudo gem install cocoapods --pre -n /usr/local/bin
This works for me.