13

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

botbot
  • 6,848
  • 12
  • 53
  • 93

11 Answers11

19

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

jazzyfresh
  • 701
  • 1
  • 6
  • 11
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

Meltemi
  • 36,348
  • 48
  • 182
  • 274
  • 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 04 '12 at 04:18
  • for example, here http://siliconchaos.com/2011/07/installing-rails-with-rvm/ says to run 'gem install rails'. is that not right? – botbot Dec 04 '12 at 04:19
6

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

Vincent Guerci
  • 14,094
  • 4
  • 47
  • 55
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.

joan
  • 2,145
  • 2
  • 22
  • 27
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.

Dipak Panchal
  • 5,782
  • 4
  • 29
  • 62
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.

jsteinmann
  • 3,494
  • 2
  • 15
  • 20
  • 1
    Personally, I'd recommend RVM + Homebrew. – Alistair A. Israel Dec 04 '12 at 03:49
  • The take away from this answer is don't use the built in tool. Both railsinstaller and RVM + homebrew are great choices. – sunnyrjuneja Dec 04 '12 at 03:52
  • @AlistairIsrael thanks for the comments about rvm... so i just run 'rvm install rails' and let 'er rip? – botbot Dec 04 '12 at 04: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 04 '12 at 04: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 04 '12 at 04: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.

David Stosik
  • 821
  • 9
  • 17
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/

Pouya
  • 1,867
  • 3
  • 17
  • 16
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.

roxdurazo
  • 675
  • 9
  • 20
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

Neil
  • 41
  • 4
0

After a new

gem install rails

do

rbenv rehash

It worked for me.