Mac OS X Mountain Lion “Rails is not currently ins

2019-03-09 13:07发布

问题:

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:

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:

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



回答3:

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



回答4:

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.



回答5:

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.



回答6:

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.



回答7:

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.



回答8:

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/



回答9:

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.



回答10:

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