Ruby-on-rails 为什么我不能使用 RVM 在 Lion 上安装 Rails?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6170813/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 01:16:46  来源:igfitidea点击:

Why can't I install Rails on Lion using RVM?

ruby-on-railsrubymacosrvm

提问by Michael Jerome

I'm running into issues trying to install Rails on OS X Lion using RVM.

我在尝试使用 RVM 在 OS X Lion 上安装 Rails 时遇到问题。

So far, I have done the following:

到目前为止,我已经完成了以下工作:

  1. Installed Mac OS X Lion Version 10.7 (Build 11A459e).
  2. Installed XCode 4.1 Developer Preview 5.
  3. Installed RVM.
  4. Installed a 1.8.7 version of Ruby via RVM using the command rvm install 1.8.7. Note: I need to be using 1.8.7 and not 1.9.2.
  5. Switched to the 1.8.7 version of Ruby using the command rvm 1.8.7.
  6. Created a new gemset using the command rvm gemset create rails3.
  7. Switched to the new gemset using the command rvm use 1.8.7@rails3.
  8. To install Rails I ran the command gem install railsbut I got the following error:

    /Users/m/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault

  1. 已安装 Mac OS X Lion 版本 10.7(内部版本 11A459e)。
  2. 安装了 XCode 4.1 Developer Preview 5。
  3. 已安装 RVM。
  4. 使用命令通过 RVM 安装了 1.8.7 版本的 Ruby rvm install 1.8.7。注意:我需要使用 1.8.7 而不是 1.9.2。
  5. 使用命令切换到 Ruby 的 1.8.7 版本rvm 1.8.7
  6. 使用命令创建了一个新的 gemset rvm gemset create rails3
  7. 使用命令切换到新的 gemset rvm use 1.8.7@rails3
  8. 要安装 Rails,我运行了命令,gem install rails但出现以下错误:

    /Users/m/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/timeout.rb:60: [BUG] 分段错误

The same error happens when trying to run any gem command so I don't think it's really a problem with Rails.

尝试运行任何 gem 命令时都会发生同样的错误,所以我认为这不是 Rails 的真正问题。

Judging by the links below, I don't seem to be the only person having this issue:

从下面的链接来看,我似乎不是唯一遇到这个问题的人:

http://twitter.com/#!/pingles/status/66261101351927809and https://github.com/carlhuda/bundler/issues/1058

http://twitter.com/#!/pingles/status/66261101351927809https://github.com/carlhuda/bundler/issues/1058

回答by Michael Jerome

Fixed it!

修复!

The answer was actually on one of the links I posted above. Before installing a version of ruby (rvm install 1.8.7) I needed to run "export CC=/usr/bin/gcc-4.2". With that in place, everything ran smoothly.

答案实际上是在我上面发布的链接之一上。在安装 ruby​​ 版本(rvm install 1.8.7)之前,我需要运行“ export CC=/usr/bin/gcc-4.2”。有了这个,一切都进行得很顺利。

If you don't want to have CCpermanently exported, you can do CC=/usr/bin/gcc-4.2 rvm install 1.8.7

如果你不想CC永久导出,你可以这样做CC=/usr/bin/gcc-4.2 rvm install 1.8.7

If you have already installed ruby 1.8.7. Just do CC=/usr/bin/gcc-4.2 rvm reinstall 1.8.7

如果您已经安装了 ruby​​ 1.8.7。做就是了CC=/usr/bin/gcc-4.2 rvm reinstall 1.8.7

回答by Matt Sanders

If you have installed Xcode 4.2, it actually doesn't install non-LLVM gcc anymore, so you have to add it. For some reason downgrading to 4.1 after you've installed 4.2 doesn't work correctly (at least it didn't for me and others have had similar issues).

如果你已经安装了 Xcode 4.2,它实际上不再安装非 LLVM gcc,所以你必须添加它。由于某种原因,在安装 4.2 后降级到 4.1 无法正常工作(至少对我来说不是这样,其他人也有类似的问题)。

After quite a bit of thrashing, this is what finally worked for me:

经过一番折腾,这终于对我有用了:

  1. Install Xcode 4.2 from App Store
  2. Install darwin gcc using the OSX gcc installer
  3. Install REE making sure you remove any vestiges of previous attempts:
  1. 从 App Store 安装 Xcode 4.2
  2. 使用OSX gcc 安装程序安装 darwin gcc
  3. 安装 REE,确保删除以前尝试的任何痕迹:

Close any open terminal windows, open a fresh one and

关闭所有打开的终端窗口,打开一个新窗口,然后

rvm remove ree
export CC=/usr/bin/gcc-4.2
rvm install ree

This worked for me with rvm 1.8.6, OS X 10.7.2 and gcc-4.2 version 4.2.1 (Apple build 5666).

这对我来说适用于 rvm 1.8.6、OS X 10.7.2 和 gcc-4.2 版本 4.2.1(Apple build 5666)。

If you have already installed Xcode 4.1, resist the urge to upgrade to 4.2 and you should be okay.

如果您已经安装了 Xcode 4.1,请抵制升级到 4.2 的冲动,您应该没问题。

回答by Hans verschooten

If that still doesn't work add --force. So this becomes:

如果这仍然不起作用,请添加 --force。所以这变成了:

CC=/usr/bin/gcc-4.2 rvm install ruby-1.8.7 --force

CC=/usr/bin/gcc-4.2 rvm install ruby-1.8.7 --force

回答by HeroicEric

Make sure that you remove 1.8.7 if you already installed it before using "export CC=/usr/bin/gcc-4.2" by doing "rvm remove 1.8.7"

如果您在使用“ export CC=/usr/bin/gcc-4.2”之前已经安装了 1.8.7,请确保通过执行“ rvm remove 1.8.7”删除它

回答by KARASZI István

I had the same issue on my system. I installed the Xcode command linetools from Apple which ships with LLVM compiler and without an LLVM free one.

我的系统也有同样的问题。我安装了Apple的Xcode 命令行工具,它随 LLVM 编译器一起提供,但没有免费的 LLVM。

Ruby 1.8.7 won't work with an LLVM compiler not even with CC=clang, so installing an LLVM free gcc solves the problem.

Ruby 1.8.7 甚至不能与 LLVM 编译器一起使用CC=clang,因此安装一个 LLVM free gcc 可以解决这个问题。

There are multiple options listed here:

这里列出了多个选项:

https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers

https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers

Long story short, install GCC v4.2 with Homebrew:

长话短说,使用Homebrew安装 GCC v4.2 :

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb

and theninstall ruby 1.8.7:

安装Ruby 1.8.7:

CC=gcc-4.2 rvm install 1.8.7

回答by xpepermint

Instead of "export CC=/usr/bin/gcc-4.2" do "export CC=gcc" (xCode 4.2.x should be installed).

而不是 " export CC=/usr/bin/gcc-4.2" do " export CC=gcc"(应该安装 xCode 4.2.x)。

回答by Rimian

Check which version of gcc you have like this:

检查您使用的是哪个版本的 gcc:

ls -Al `which gcc-4.2`

I followed the instructions here: http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion

我按照这里的说明操作:http: //robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion

brew update
brew tap homebrew/dupes
brew install apple-gcc42

Then reinstall:

然后重新安装:

Check again what your path to gcc is (to use for CC=):

再次检查您的 gcc 路径是什么(用于 CC=):

ls -Al `which gcc-4.2`

(optional) You can set this in your .bashrc for example:

(可选)您可以在 .bashrc 中进行设置,例如:

export CC=/usr/bin/gcc-4.2

(optional) remove any old version of ruby

(可选)删除任何旧版本的 ruby

rvm remove 1.8.7

Then:

然后:

CC=/usr/local/bin/gcc-4.2 rvm --verify-downloads 1 reinstall 1.8.7-p357 --without-tcl --without-tk 

or if you have set CC in your profile

或者如果您在个人资料中设置了 CC

rvm --verify-downloads 1 reinstall 1.8.7-p357 --without-tcl --without-tk 

Note the flags on the rvm install. I had trouble verifying the checksum on the ftp server and some problems with tck and what not. You may be able to omit those flags.

请注意 rvm 安装上的标志。我无法验证 ftp 服务器上的校验和,还有一些 tck 问题以及其他问题。您可以省略这些标志。

Also: you might need to remove an old version of your gemset:

另外:您可能需要删除旧版本的 gemset:

rvm gemset delete <gemset>

Then

然后

gem install bundler
bundle install

Hope this helps.

希望这可以帮助。

回答by Michael Nikitochkin

I have same problem only for arch x86_64, when I comment line in my ~/.rvmrc

我只对 arch x86_64有同样的问题,当我在~/.rvmrc 中注释行时

rvm_archflags="-arch x86_64"

Open a new terminal and tried to install ruby-1.8.7 again

打开一个新终端并尝试再次安装 ruby​​-1.8.7

rvm install 1.8.7

It was successful.

它成功了。

回答by Henry Kim

Using macport and ruby-1.9.x version. I did successfully install rails with ruby gem.

使用 macport 和 ruby​​-1.9.x 版本。我确实使用 ruby​​ gem 成功安装了 rails。

回答by Brad Gessler

If you're using RVM in a development workflow, I added a fix in an .rvmrc file for OS X Lion.

如果您在开发工作流程中使用 RVM,我在 OS X Lion 的 .rvmrc 文件中添加了一个修复程序。

https://gist.github.com/1112962

https://gist.github.com/1112962

(updated file name)

(更新文件名)