I'm trying to install Rails 3 on a brand new MacBook Pro running OS X 10.6.3, Ruby 1.8.7, and Rails 2.3.5 and I'm wondering if I've hosed myself. So far, I've run these commands:
$ gem update --system
$ gem install arel tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
$ gem install rails --pre
However, when I run the last command, I get this error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/bin directory.
I think it wants me to run the command with sudo
so that it can write over /usr/bin/rails
. But if I do that, won't I be overwriting my Rails 2.3.5 executable? I don't want to do that. Instead, I'd like to keep both versions of Rails. How do I do that?
This question is related to
ruby-on-rails-3
On macOS High Sierra, this solved my issue:
sudo gem update --system -n /usr/local/bin/gem
This Error hit me after installing RVM correctly. Solution: re-boot Terminal.
Reference RailsCast's RVM Install tutorial.
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.
use -n
parameter to install like for cocoapods:
sudo gem install cocoapods -n /usr/local/bin
You can use sudo gem install -n /usr/local/bin cocoapods
This works for me.
For me, something different worked, that I found in on this answer from a similar question. Probably won't help OP, but maybe someone like me that had a similar problem.
You should indeed use rvm, but as no one explained to you how to do this without rvm, here you go:
sudo gem install tzinfo builder memcache-client rack rack-test rack-mount \
abstract erubis activesupport mime-types mail text-hyphen text-format \
thor i18n rake bundler arel railties rails --prerelease --force
To fix your specific error you need to run that command as sudo, ie:
sudo gem install rails --pre
Source: Stackoverflow.com