Mac OS X Mountain Lion“Rails目前还没有安装在这个系统上。”

时间:2022-06-20 20:27:44

I am on a fresh install of OS X Mountain Lion. I have installed rails via:

我正在重新安装OS X Mountain Lion。我通过以下方式安装了rails:

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命令(rails s、rails -v等)时,我得到了这个错误:

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

“which rails”的结果是/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.

我认为这是一个路径问题,也许是,但我可以看到/usr/bin是我路径的一部分。

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

更新:我注意到我的其他mac电脑上的所有操作系统都运行得很好。我就是不记得我是怎么做到的。如果我运行“which rails”,我看到它在一个完全不同的地方/用户/用户名/.rvm/gems/ruby-1.9.3-p194/bin/rails

10 个解决方案

#1


18  

Use RVM http://rvm.io or rbenv to install newer Rails versions than what come pre-installed with OS X.

利用RVM http://rvm。io或rbenv要安装新的Rails版本,而不是预先安装的OS X。

Follow examples on the site https://rvm.io/rvm/install/ but basically:

请按照https://rvm网站上的示例进行操作。io /区/安装/但基本上:

Install RVM: $ \curl -L https://get.rvm.io | bash -s stable

安装RVM: $ \curl -L https://get.rvm。io | bash -s稳定

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)

然后,您可以使用已知的$rvm列表来查看有多少红宝石可供您使用(很多)。只需$rvm安装1.9.3就可以获得Ruby的最新版本(到本文为止,Ruby -1.9.3-p327就是其中之一)

Set that ruby as your default $rvm --default use 1.9.3

将ruby设置为默认的$rvm——默认使用1.9.3

Create a default gemset to store your gems $rvm use 1.9.3@mygemset --create --default

创建一个默认的gemset来存储您的gem $rvm使用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

然后安装Rails $ gem安装Rails将使您获得当前的版本,这与输入gem安装Rails - v3.2.9是一样的

#2


17  

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

如果您正在使用rbenv,请不要忘记在安装/更新ruby之后使用rbenv rehash。

#3


6  

Just had this issue using rbenv, no idea how this happened, but figured that my ~/.rbenv/shims/rails was empty...

只是用rbenv出现了这个问题,不知道是怎么发生的,但是想到了我的~/。rbenv /垫片/ rails是空的…

So to fix this:

所以为了解决这个问题:

  • Cleaned empty shims: find ~/.rbenv/shims -empty -delete

    清洗过的空垫片:查找~/。rbenv /垫片空删除

  • Then regenerate: rbenv rehash (was not overwriting empty one...)

    然后重新生成:rbenv rehash(没有覆盖空的…)

#4


3  

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,关闭终端窗口,重新打开。然后输入:

~ $ rails -v
Rails 4.0.2

So, reseting the Terminal window fix the problem.

因此,重新设置终端窗口可以修复这个问题。

#5


1  

I think install rvm that will help you

我认为安装rvm可以帮助你

  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.

最后一行创建了一个名为current的gem集。

Now check to make sure you RubyGems was installed correctly by typing which gem in your terminal. Now update your gems.

现在,通过在终端中键入哪个gem,检查是否正确安装了RubyGems。现在更新你的宝石。

gem update --system 1.8.24

Finally install rails.

最后安装rails。

gem install rails -v 3.2.3

I hope this works, let me know if you have any issues.

如果你有什么问题,请告诉我。

#6


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.

是的,OSX为Ruby on Rails以及PHP、Mysql等提供了很多优秀的软件。但是,有时使用第三方安装程序来获取所需的所有内容,而不需要通过/usr/目录进行挖掘,对于维护目的来说更好。

I recommend checking out http://railsinstaller.org/

我建议您查看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.

通过一个简单的安装,您就拥有了Rails项目所需的一切,包括人们使用的普通软件,该站点甚至还有教程。我建议走这条路。这样会节省您的时间。此外,它还附带了一个简单的卸载程序,如果您对配置不满意,可以将其放入您的应用程序文件夹中删除。享受。

#7


0  

Actually, /usr/bin/rails script is just a

实际上,/usr/bin/rails脚本就是a

# Stub rails command to load rails from Gems or print an error if not installed.

存根rails命令从Gems加载rails,如果没有安装则打印错误。

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

如果安装了Rails,则加载它。否则,脚本将抛出您在问题中粘贴的错误。

#8


0  

Yet, another alternative to RVM is the awesome rbenv tool.

然而,RVM的另一个替代选择是令人敬畏的rbenv工具。

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.

它非常容易安装(只是一个简单的brew安装rbenv)和使用。在我看来,这是在Mac上管理你的红宝石的最好方法。

However, if you have rvm installed on your machine already, consider removing it from your system by doing rvm implode.

但是,如果您已经在您的机器上安装了rvm,请考虑通过执行rvm内爆从系统中删除它。

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.

由于建立一个新的ruby on rails开发环境是大多数新手(包括刚开始使用rails时我自己)的常见障碍,我在一篇博客文章中详细介绍了如何做到这一点,我将链接到下面。希望你会觉得它有用。

http://blog.parsalabs.com/blog/2013/08/27/setting-up-a-ruby-on-rails-4-development-environment-on-a-clean-mac-os-x-installation/

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


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

我得到了相同的错误并卸载了rvm,然后按照这个页面上的说明:https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rail on-ubuntu- 12-04-lts-precision -pangolin-with-rvm

i think that help was

我认为那是帮助

rvm requirements

on the terminal.

在终端上。

#10


0  

Our company uses a script to setup each new machine with a Rails dev environment:

我们公司使用一个脚本设置每个新机器与Rails开发环境:

We've open source it, give it a try: https://github.com/platform45/let-there-be-light

我们已经开放了它的源代码,请尝试一下:https://github.com/platform45/let-there-be light

#1


18  

Use RVM http://rvm.io or rbenv to install newer Rails versions than what come pre-installed with OS X.

利用RVM http://rvm。io或rbenv要安装新的Rails版本,而不是预先安装的OS X。

Follow examples on the site https://rvm.io/rvm/install/ but basically:

请按照https://rvm网站上的示例进行操作。io /区/安装/但基本上:

Install RVM: $ \curl -L https://get.rvm.io | bash -s stable

安装RVM: $ \curl -L https://get.rvm。io | bash -s稳定

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)

然后,您可以使用已知的$rvm列表来查看有多少红宝石可供您使用(很多)。只需$rvm安装1.9.3就可以获得Ruby的最新版本(到本文为止,Ruby -1.9.3-p327就是其中之一)

Set that ruby as your default $rvm --default use 1.9.3

将ruby设置为默认的$rvm——默认使用1.9.3

Create a default gemset to store your gems $rvm use 1.9.3@mygemset --create --default

创建一个默认的gemset来存储您的gem $rvm使用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

然后安装Rails $ gem安装Rails将使您获得当前的版本,这与输入gem安装Rails - v3.2.9是一样的

#2


17  

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

如果您正在使用rbenv,请不要忘记在安装/更新ruby之后使用rbenv rehash。

#3


6  

Just had this issue using rbenv, no idea how this happened, but figured that my ~/.rbenv/shims/rails was empty...

只是用rbenv出现了这个问题,不知道是怎么发生的,但是想到了我的~/。rbenv /垫片/ rails是空的…

So to fix this:

所以为了解决这个问题:

  • Cleaned empty shims: find ~/.rbenv/shims -empty -delete

    清洗过的空垫片:查找~/。rbenv /垫片空删除

  • Then regenerate: rbenv rehash (was not overwriting empty one...)

    然后重新生成:rbenv rehash(没有覆盖空的…)

#4


3  

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,关闭终端窗口,重新打开。然后输入:

~ $ rails -v
Rails 4.0.2

So, reseting the Terminal window fix the problem.

因此,重新设置终端窗口可以修复这个问题。

#5


1  

I think install rvm that will help you

我认为安装rvm可以帮助你

  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.

最后一行创建了一个名为current的gem集。

Now check to make sure you RubyGems was installed correctly by typing which gem in your terminal. Now update your gems.

现在,通过在终端中键入哪个gem,检查是否正确安装了RubyGems。现在更新你的宝石。

gem update --system 1.8.24

Finally install rails.

最后安装rails。

gem install rails -v 3.2.3

I hope this works, let me know if you have any issues.

如果你有什么问题,请告诉我。

#6


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.

是的,OSX为Ruby on Rails以及PHP、Mysql等提供了很多优秀的软件。但是,有时使用第三方安装程序来获取所需的所有内容,而不需要通过/usr/目录进行挖掘,对于维护目的来说更好。

I recommend checking out http://railsinstaller.org/

我建议您查看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.

通过一个简单的安装,您就拥有了Rails项目所需的一切,包括人们使用的普通软件,该站点甚至还有教程。我建议走这条路。这样会节省您的时间。此外,它还附带了一个简单的卸载程序,如果您对配置不满意,可以将其放入您的应用程序文件夹中删除。享受。

#7


0  

Actually, /usr/bin/rails script is just a

实际上,/usr/bin/rails脚本就是a

# Stub rails command to load rails from Gems or print an error if not installed.

存根rails命令从Gems加载rails,如果没有安装则打印错误。

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

如果安装了Rails,则加载它。否则,脚本将抛出您在问题中粘贴的错误。

#8


0  

Yet, another alternative to RVM is the awesome rbenv tool.

然而,RVM的另一个替代选择是令人敬畏的rbenv工具。

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.

它非常容易安装(只是一个简单的brew安装rbenv)和使用。在我看来,这是在Mac上管理你的红宝石的最好方法。

However, if you have rvm installed on your machine already, consider removing it from your system by doing rvm implode.

但是,如果您已经在您的机器上安装了rvm,请考虑通过执行rvm内爆从系统中删除它。

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.

由于建立一个新的ruby on rails开发环境是大多数新手(包括刚开始使用rails时我自己)的常见障碍,我在一篇博客文章中详细介绍了如何做到这一点,我将链接到下面。希望你会觉得它有用。

http://blog.parsalabs.com/blog/2013/08/27/setting-up-a-ruby-on-rails-4-development-environment-on-a-clean-mac-os-x-installation/

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


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

我得到了相同的错误并卸载了rvm,然后按照这个页面上的说明:https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rail on-ubuntu- 12-04-lts-precision -pangolin-with-rvm

i think that help was

我认为那是帮助

rvm requirements

on the terminal.

在终端上。

#10


0  

Our company uses a script to setup each new machine with a Rails dev environment:

我们公司使用一个脚本设置每个新机器与Rails开发环境:

We've open source it, give it a try: https://github.com/platform45/let-there-be-light

我们已经开放了它的源代码,请尝试一下:https://github.com/platform45/let-there-be light