简体   繁体   English

Mac OS X Mountain Lion“此系统上当前未安装Rails”。

[英]Mac OS X Mountain Lion “Rails is not currently installed on this system.”

I am on a fresh install of OS X Mountain Lion. 我正在全新安装OS X Mountain Lion。 I have installed rails via: 我通过以下方式安装了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是我的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. 更新:我注意到我的其他mac上的所有内容都使用相同的操作系统非常好...我只是记不清楚我是如何以这种方式工作的。 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 如果我运行'哪个轨道',我看到它在一个完全不同的地方/Users/username/.rvm/gems/ruby-1.9.3-p194/bin/rails

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来安装比预装OS X更新的Rails版本。

Follow examples on the site https://rvm.io/rvm/install/ but basically: 请关注网站https://rvm.io/rvm/install/上的示例,但基本上:

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

You can then $ rvm list known to see what Rubies are available to you (lots). 然后你就可以rvm list known $ rvm list known ,看看你可以使用什么红宝石(很多)。 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 install 1.9.3即可获得最新版本的Ruby(截至本文撰写时为ruby-1.9.3-p327

Set that ruby as your default $ rvm --default use 1.9.3 将ruby设置为默认的$ rvm --default use 1.9.3

Create a default gemset to store your gems $ rvm use 1.9.3@mygemset --create --default 创建一个默认的gemset来存储你的宝石$ 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 然后安装Rails $ gem install rails将获得最新信息,这与今天输入gem install rails -v 3.2.9

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

Just had this issue using rbenv , no idea how this happened, but figured that my ~/.rbenv/shims/rails was empty... 刚刚使用rbenv这个问题,不知道这是怎么回事,但想到我的~/.rbenv/shims/rails是空的......

So to fix this: 所以解决这个问题:

  • Cleaned empty shims: find ~/.rbenv/shims -empty -delete 清理空垫片: find ~/.rbenv/shims -empty -delete

  • Then regenerate: rbenv rehash (was not overwriting empty one...) 然后重新生成: rbenv rehash (没有覆盖空的......)

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会对你有所帮助

  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. 现在检查以确保通过在终端中键入which gem来正确安装RubyGems。 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. 是的,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. 通过一个简单的安装,您可以获得Rails项目所需的一切,包括人们使用的常用软件,并且该站点甚至还有一个教程。 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. 此外,它附带一个简单的卸载程序,如果您对配置不满意,它将放入您的Applications文件夹中删除。 Enjoy. 请享用。

Actually, /usr/bin/rails script is just a 实际上,/ usr / bin / rails脚本只是一个

# Stub rails command to load rails from Gems or print an error if not installed. #Stub rails命令从Gems加载rails,如果没有安装则打印错误。

(Comment quoted from the very script's source) (评论引自剧本的来源)

If Rails is installed, then it is loaded. 如果安装了Rails,则会加载它。 Else, the script will throw the error you pasted in your question. 否则,脚本将抛出您在问题中粘贴的错误。

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. 它非常容易安装(只需简单的brew install rbenv )并可以使用。 In my opinion, it is the best way to manage your rubies on a Mac. 在我看来,这是在Mac上管理红宝石的最佳方式。

However, if you have rvm installed on your machine already, consider removing it from your system by doing rvm implode . 但是,如果您的计算机上已经安装了rvm,请考虑通过执行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. 因为在rails dev环境中设置一个新鲜的ruby是大多数新手的常见障碍(包括我自己开始使用rails时)我已经在博客文章中详细说明了如何做到这一点,我将链接到下面。 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/ 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 我得到相同的错误并卸载rvm然后我按照此页面上的说明https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04- LTS-精确-穿山甲与- 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: 我们公司使用脚本使用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

After a new 一个新的

gem install rails

do

rbenv rehash

It worked for me. 它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM