简体   繁体   English

在Mountain Lion上安装Rails

[英]Installing Rails on Mountain Lion

I was wondering if you could help me find why I cannot install Ruby on Rails on my MBP with OS X Mountain Lion. 我想知道您是否可以帮助我找到为什么无法在OS X Mountain Lion的MBP上安装Ruby on Rails的原因。 It's a weird problem and I'll give you as much info as I can. 这是一个奇怪的问题,我会尽力为您提供更多信息。


I've installed ruby and it's working at version 1.9.3 我已经安装了ruby,并且在1.9.3版本下工作

And I've installed ruby gems and it's worked for every other gem I've tried to install. 而且我已经安装了ruby宝石,并且它可用于我尝试安装的所有其他宝石。
It's version is 1.8.24 它的版本是1.8.24

When I run $ sudo gem install rails it replies with the message: Successfully installed rails-3.2.8 1 gem installed 当我运行$ sudo gem install rails它会回答以下消息: Successfully installed rails-3.2.8 1 gem installed

Although when I ask it rails -v it returns: 虽然当我问它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.`

What should I do? 我该怎么办?


The rails bash file ( /usr/bin/rails ) contains: rails bash文件( /usr/bin/rails )包含:

#!/usr/bin/ruby
# Stub rails command to load rails from Gems or print an error if not installed.
require 'rubygems'

version = ">= 0"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
    ARGV.shift
end

begin
    gem 'railties', version or raise
rescue Exception
    puts 'Rails is not currently installed on this system. To get the latest version, simply type:'
    puts
    puts '    $ sudo gem install rails'
    puts
    puts 'You can then rerun your "rails" command.'
    exit 0
end

load Gem.bin_path('railties', 'rails', version)

That must mean that the gem files aren't there or are old or corrupted 这必须表示gem文件不存在,文件已旧或已损坏
How can I check that? 我该如何检查?

Starting with a fresh install of Mountain Lion... 从全新安装Mountain Lion开始...

I tried using, 我尝试使用

sudo gem install rails

...straight out of the box. 开箱即用 This gave errors summarised by, 这给出了错误总结,

ERROR: Failed to build gem native extension.

However, this same command succeeded after I installed the Xcode command line tools via, 但是,通过安装Xcode命令行工具后,该命令成功完成,

Xcode 4.5.2 -> Preferences -> Download -> Components

I made no other changes other than installing the command line tools. 除了安装命令行工具外,我没有进行任何其他更改。

我建议您使用此资源来安装Rails及其所需的一切。

Railsinstaller发布了OSX的安装程序,尝试从git存储库https://github.com/railsinstaller下载他们的安装程序(似乎有人破坏了他们的官方网页)。

I installed Mountain Lion on my Macbook the other day. 前几天,我在Macbook上安装了Mountain Lion。 I used Homebrew to install RVM (and followed the post-install instructions!), then used RVM to install the latest version of Ruby (1.9.3). 我使用Homebrew来安装RVM(并遵循安装后的指示!),然后使用RVM来安装最新版本的Ruby(1.9.3)。 From there I set 1.9.3 as the default and then ran gem install rails . 从那里我将1.9.3设置为默认值,然后运行gem install rails So far it has ran without a hitch! 到目前为止,它运行顺利!

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

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