14

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

1
  • What does which ruby return? If it's /usr/bin/ruby, try rvm use 1.9.3. Dec 4, 2012 at 5:19

11 Answers 11

19

If you're using rbenv, don't forget to rbenv rehash after installing/updating ruby.

0
18

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

2
  • can you post a usage example? i feel like i did use rvm because i rand gem install rails? what is the command i should use? thanks!
    – botbot
    Dec 4, 2012 at 4:18
  • for example, here siliconchaos.com/2011/07/installing-rails-with-rvm says to run 'gem install rails'. is that not right?
    – botbot
    Dec 4, 2012 at 4:19
8

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...)

1
  • Thank you! This fixed it for me!
    – robyoder
    Oct 14, 2014 at 21:48
2

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.

1
  • 1
    it may look weird but this fixed the problem for me
    – jrenouard
    May 13, 2014 at 15:13
1

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.

2
  • did you select rvm? for example - rvm use your gemset name Dec 4, 2012 at 4:38
  • gem update --system then sudo gem install rails -V without the version numbers worked for me Nov 21, 2015 at 6:47
0

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.

5
  • 1
    Personally, I'd recommend RVM + Homebrew. Dec 4, 2012 at 3:49
  • The take away from this answer is don't use the built in tool. Both railsinstaller and RVM + homebrew are great choices. Dec 4, 2012 at 3:52
  • @AlistairIsrael thanks for the comments about rvm... so i just run 'rvm install rails' and let 'er rip?
    – botbot
    Dec 4, 2012 at 4:10
  • @rockstarz i think i am a bit apprehensive to use a 3rd party installer. i appreciate the suggestion and did look into that tool. probably will be a lot easier in the future, maybe even this is the "one click solution", but, at this point i feel it's a bit like taking out an anthill with a nuke. worried it's going to screw up my configuration and install too many things in places i am not familiar with and ultimately make me rely on it's config.
    – botbot
    Dec 4, 2012 at 4:17
  • railsinstaller comes with RVM. It installs Ruby 1.9.3-p194 , Rails 3.2.7 , Git 1.7.9.6 , Sqlite 3070500 , osx-gcc-installer 4.1 , JewelryBox 1.3.0 , RVM 1.14.2 , SM 0.10.3, and an uninstaller that removes the configuration. It doesn't mess up your current stuff
    – jsteinmann
    Dec 4, 2012 at 4:19
0

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.

0

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/

0
0

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.

0

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

-1

After a new

gem install rails

do

rbenv rehash

It worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.