I've read all the other Stackoverflow posts on this problem but don't see any suitable solution for rbenv, so i'll post it on here. (most of the other posts suggest either using RVM, or the OP had already ran sudo gem install rails).
when i run gem install rails (without sudo), i get
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
is /Library/Ruby/Gems/2.0.0 the correct spot?
why am i getting this error? i'm on a fresh laptop that hasn't had much install.
i've got homebrew, rbenv, and ruby 2.0
rbenv should not be trying to install to your System install of Ruby. If you check the permissions on /Library/Ruby/Gems/2.0.0 you'll see it's owned by root, which means you'll need to sudo to write to it, which we're trying to avoid.
This suggests that either
There is something wrong with your rbenv installation, because it should be looking at /Users/whoami/.rbenv/versions/2.0.0. As you can see in their documentation. I'd confirm that your rbenv is operating correctly or maybe try reinstalling to make sure your rbenv installation of ruby is taking priority.
Your system ruby might be clobbering your rbenv. Have you made sure that your system ruby isn't taking precedence in your path? Try running gem list rake -d with a gem you already have installed to see where your gems are currently installed
Related
After reading about Ruby gems and having no idea what rbenv or RVM was, I figured I should probably have one of the two.
I tried installing rbenv using Homebrew however it told me I had already installed rbenv. I always seem to have problems adding gems and usually end up using the sudo command to get it to work (which is a horrible idea I assume).
I discovered I had these problems when I was trying to add the braintree API gem and got an error whenever I tried to start the server.
Commands I tried:
gem install "braintree"
bundle install
sudo gem install "braintree"
The error received from running rails server was:
"/config/initializers/braintree.rb:2:in `<top (required)="">': uninitialized constant Braintree::Configuratio (NameError)"
To take it from the top, rbenv and RVM are Ruby version managers. This means that you can have multiple versions of Ruby installed on your computer at once and select which one you would like to use. I have used both and personally like rbenv's approach.
With that said I think you need to remove the quotes from around the name of the gem you are installing.
Also, in your Gemfile do you have the braintree gem listed? It should be as simple as gem 'braintree'.
If you have multiple versions of Ruby installed or even if you just have the system Ruby and a version installed with RVM or rbenv you may be starting your Rails server with the wrong Ruby version (ie it is missing the gem). You can see if it is using rbenv by typing which ruby and it should print something out with .rbenv/ whatever. If not you need to set rbenv as your current ruby. You can do that like rbenv global 2.1.1 where 2.1.1 is the version of ruby you installed with rbenv. If you haven't installed a version with rbenv you can use ruby-build and do rbenv install 2.1.1 or whatever version you want. Then when you launch your Rails server prefixing the command with bundle exec.
You can set a local ruby-version for your directory by executing rbenv local 2.1.1 once again where 2.1.1 is the version you want.
Reading the rbenv docs will go a long way.
To check if you are using rbenv, simply use this
rbenv
*check if 'rbenv' commands were listed
Same with rvm use
rvm
Run the command rbenv in terminal. If you have rbenv installed, it will list some help commands. If rbenv is not installed, it will output something like "No command 'rbenv' found"
Run the command rvm in terminal. If you have RVM installed, it will list some help commands. If rvm is not installed, it will output something like "No command 'rvm' found"
I am trying to install Rails on my Mac Version 10.9.5 and something is not working as when I try to see which version of Rails I have installed I get the following:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/rbconfig.rb:213: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
If I try to run that command, this is what I am getting...
sudo gem install rails
Password:
dyld: Library not loaded: /usr/local/lib/libgmp.10.dylib
Referenced from: /Users/ppmartins/.rvm/rubies/ruby-2.1.3/bin/ruby
Reason: image not found
Any idea about what's happening and how to solve this issue?
Thank you all.
It is best to never use your system Ruby to install Gems. System Ruby is a version of Ruby that ships with your Mac. OSX uses Ruby for various tasks, so it is best to leave it alone and not risk corrupting any Gems.
Instead, you should use Ruby version managers to install versions of Ruby that your system won't rely on. Using sudo is also not necessary for these versions. If you find yourself needing to do this, you might be (ab)using your system Ruby.
Personally I use rbenv since it integrates well with Homebrew, but there are others such RVM as well.
Try following http://installrails.com/
It runs you step by step through setting up an environment on your computer. :D
It's pretty straight forward compared with googling rbenv, RVM etc
Hope this helps!
Dump rvm and use rbenv. You haven't set it up correctly anyway
Don't use sudo when installing gems
Make sure your don't use system Ruby from '/Library'
So,
Install Homebrew http://brew.sh
Install Rbenv brew install rbenv
Install Ruby Build brew install ruby-build
Install Ruby rbenv install 2.1.2
Make it a default interpreter rbenv global 2.1.2
That's the gist of it. There might be some things you need to do manually like adding rbenv path to your .bash_profile.
Update I was downvoted? Haha, why?
I am on a fresh install of OS X Mountain Lion. I have installed rails via:
sudo gem install rails
Everything seems to install correctly, but when I type the rails command (rails s, rails -v, etc), I get this error:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
The result of 'which rails' is /usr/bin/rails
I thought it was a path issue, and perhaps it is, but I can see that /usr/bin is part of my PATH.
Any help? Thanks!
UPDATE: I noticed everything on my other mac with same exact OS works pretty well... I just can't remember how I got it to work that way. If I run 'which rails' I see it's in a totally different place /Users/username/.rvm/gems/ruby-1.9.3-p194/bin/rails
If you're using rbenv, don't forget to rbenv rehash after installing/updating ruby.
Use RVM http://rvm.io or rbenv to install newer Rails versions than what come pre-installed with OS X.
Follow examples on the site https://rvm.io/rvm/install/ but basically:
Install RVM: $ \curl -L https://get.rvm.io | bash -s stable
You can then $rvm list known to see what Rubies are available to you (lots). And simply $rvm install 1.9.3 to get the most current version of Ruby (which as of this writing is ruby-1.9.3-p327)
Set that ruby as your default $rvm --default use 1.9.3
Create a default gemset to store your gems $rvm use 1.9.3#mygemset --create --default
Then install Rails $ gem install rails will get you current which today is same as typing gem install rails -v 3.2.9
Just had this issue using rbenv, no idea how this happened, but figured that my ~/.rbenv/shims/rails was empty...
So to fix this:
Cleaned empty shims: find ~/.rbenv/shims -empty -delete
Then regenerate: rbenv rehash (was not overwriting empty one...)
I had the same problem.
After typing:
sudo gem install rails
and installing rails correctly, just close the Terminal window and open again. Then type:
~ $ rails -v
Rails 4.0.2
So, reseting the Terminal window fix the problem.
I think install rvm that will help you
rvm get head && rvm reload
rvm install 1.9.3
rvm use 1.9.3#current --create --default
The last line creates a gem set called current.
Now check to make sure you RubyGems was installed correctly by typing which gem in your terminal. Now update your gems.
gem update --system 1.8.24
Finally install rails.
gem install rails -v 3.2.3
I hope this works, let me know if you have any issues.
Yes, OSX comes standard with a lot of great software for Ruby on Rails, as well as PHP, Mysql, etc. However, sometimes it's better for sustainment purposes to use a 3rd party installer to get everything you want without digging through your /usr/ directory.
I recommend checking out http://railsinstaller.org/
With one easy install, you have everything you could want for a Rails project, including common software people use, and the site even has a tutorial. I recommend going this way. It saves you time. Plus, it comes with an easy uninstaller that it will put in your Applications folder to remove if you're not happy with the configuration. Enjoy.
Actually, /usr/bin/rails script is just a
# Stub rails command to load rails from Gems or print an error if not installed.
(Comment quoted from the very script's source)
If Rails is installed, then it is loaded. Else, the script will throw the error you pasted in your question.
Yet, another alternative to RVM is the awesome rbenv tool.
It is very easy to install (just a simple brew install rbenv) and work with. In my opinion, it is the best way to manage your rubies on a Mac.
However, if you have rvm installed on your machine already, consider removing it from your system by doing rvm implode.
Since setting up a fresh ruby on rails dev environment is a common barrier to most newbies (including myself when i started off with rails) I've put together detailed instructions on how to do exactly that in a blog post, which i will link to below. Hope you will find it useful.
http://blog.parsalabs.com/blog/2013/08/27/setting-up-a-ruby-on-rails-4-development-environment-on-a-clean-mac-os-x-installation/
i got the same error and uninstall rvm then i follow the instructions on this page https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
i think that help was
rvm requirements
on the terminal.
Our company uses a script to setup each new machine with a Rails dev environment:
We've open source it, give it a try: https://github.com/platform45/let-there-be-light
After a new
gem install rails
do
rbenv rehash
It worked for me.
This has driven me crazy. I changed laptop and tried getting my Rails environment working again. Mac OS X has its own ruby, but I used brew and installed new. I installed rails 3.0.5, ran:
bundle install
Then:
rails s
I got this error:
Could not find aws-s3-0.6.2 in any of the sources
Run `bundle install` to install missing gems.
After bashing my head against a wall for a couple hours, I tried just manually installing the gems and it worked! So, apparently, rails and bundler are looking at different places for my gems. Both are from my brew install.
How can I figure out what each is looking at so I can use "bundle install" again?
Rails and Bundle are looking at the gems providing they are in the bundle.
Use the
bundle show
command to see the gems Rails is having access to via bundler.
Also you can examine the Gemfile.lock file.
The gemfile sources mainly from rubygems.org as supposed to rubyforge (which came up when i searched that gem on google). I think the gem command will check both. You can specify additional sources, as mentioned in the readme: http://gembundler.com/man/gemfile.5.html
Are you using pow? I've been having this issue with Pow starting up with one version of ruby, but not the version that I have RVM currently set to.
I have not tried it yet, but this issue on Github mentions the problem and refers people to the Pow trouble shooting here. I've pasted the contents below:
RVM
Incorrect ruby or gemset is being used
Create a .rvmrc at your project root. See rvmrc docs.
System-wide RVM install
If you have a system-wide RVM install and are getting the error LoadError: no such file to load -- bundler/setup, run rvm info to find out where rvm is installed on your machine, then do this:
echo "export POW_RVM_PATH=/usr/local/rvm/scripts/rvm" >> ~/.powconfig
Where /usr/local/rvm/ is the location of your rvm installation.
Then restart POW by killing it in the Activity Monitor or in Terminal.
I currently have rails 3.0.3 and am trying to download and use version 3.0.1. I've downloaded and installed RVM and inputted the following code in Terminal (I have a Mac OS X 10.6.5):
rvm use 1.8.7
rvm gemset create rails3.0.1
rvm 1.8.7#rails3.0.1
sudo gem install rails --version=3.0.1
I use sudo gems because of the user permissions, or my lack there of. Anyway, after I enter the last line of code: "sudo gem install rails --version=3.0.1" I get the following error:
Successfully installed rails-3.0.1
1 gem installed
Installing ri documentation for rails-3.0.1...
File not found: lib
Not only can I apparently not able to switch versions of rails, even though it appears as though I have multiple versions installed, every time I try to check to see what version of rails I currently have I get the following result:
rails -v
/Library/Ruby/Site/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems.rb:214:in `activate'
from /Library/Ruby/Site/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
Also, I've already installed Rdoc and Xcode (I've done research and other suggestions pointed to installing both). I'm a RoR newbie, and especially an RVM newbie, so I would love an explanation and a solution to this madness.
Thank you for reading!
I think you went off the rails (ha-ha) right here:
sudo gem install rails --version=3.0.1
The RVM documentation has this to say about that:
DO NOT use sudo...
to work with RVM gems. When you do
sudo you are running commands as root,
another user in another shell and
hence all of the setup that RVM has
done for you is ignored while the
command runs under sudo (such things
as GEM_HOME, etc...). So to reiterate,
as soon as you 'sudo' you are running
as the root system user which will
clear out your environment as well as
any files it creates are not able to
be modified by your user and will
result in strange things happening.
(You will start to think that someone
has a voodoo doll of your
application...)