By default, the owner and group of /usr/local and all subdirectories (including bin ) should be root. root and the permissions should be rwxr-xr-x . This means that users of the system can read and execute in (and from) this directory structure, but cannot create or edit files there.
-- /usr/bin This is the primary directory for executable programs. Most programs executed by normal users which are not needed for booting or for repairing the system and which are not installed locally should be -- /usr/local/bin Binaries for programs local to the site.
"usr" stands for UNIX System Resources. This is the location that system programs and libraries are stored. "local" represents resources that were not shipped with the standard distribution and, usually, compiled and maintained on a per site basis. "bin" represents binary compiled executables.
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.
You can use sudo gem install -n /usr/local/bin cocoapods
This works for me.
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
To fix your specific error you need to run that command as sudo, ie:
sudo gem install rails --pre
This Error hit me after installing RVM correctly. Solution: re-boot Terminal.
Reference RailsCast's RVM Install tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With