无法在OSX 10.7.5上安装Rails。

4
每当我运行
    sudo gem install rails

我得到了以下输出:
   ERROR:  Loading command: install (LoadError)
cannot load such file -- openssl
ERROR:  While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

RVM版本:rvm 1.18.14,Ruby版本为2.0.0p0。

5个回答

8
您需要重新安装Ruby:
rvm get head --autolibs=3
rvm pkg remove
rvm reinstall all --force

新的autolibs支持将负责更新ruby依赖项并将其包含在其中。

当我尝试重新安装时:运行错误 'env LDFLAGS=-L/opt/sm/pkg/active/lib CFLAGS=-I/opt/sm/pkg/active/include CPATH=/opt/sm/pkg/active/include ./configure --prefix=/Users/moza/.rvm/rubies/ruby-2.0.0-p0 --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/readline:/usr/local/opt/libxml2:/usr/local/opt/libxslt:/usr/local/opt/libksba:/usr/local/opt/openssl:/usr/local/opt/sqlite --disable-install-doc --without-tcl --without-tk --enable-shared',请阅读 /Users/moza/.rvm/log/ruby-2.0.0-p0/configure.log 在运行 configure 时发生错误。 停止安装。 - mikhail90
你可能遇到了另一个问题,请确保运行以下命令:rvm get head 并阅读所有输出,然后使用 rvm reinstall ruby--autolibs=3 进行安装。 - mpapis

4

您的系统上安装了Homebrew吗?如果是,请尝试:

brew install openssl

在命令行中执行。

2
此外,您需要在之后重新安装Ruby或重新编译openssl扩展。 - Lee Jarvis
我已经尝试过了:`brew install openssl 警告:您的Xcode(4.5.1)已过期 请安装Xcode 4.6。 错误:openssl-1.0.1e已经安装` - mikhail90
更新后,brew可以正常工作,但在安装rails时,我遇到了以下错误:/Users/moza/.rvm/bin/gem: line 6: /Users/moza/.rvm/bin/gem: Argument list too long/Users/moza/.rvm/bin/gem: line 6: /Users/moza/.rvm/bin/gem: Undefined error: - mikhail90

3
嗯,你有rvm,但为什么需要sudo呢?我以为rvm处于沙盒模式。无论如何,错误只是意味着它找不到ssl路径。首先,请确保你已经安装了openssl。如果没有安装,则需要安装它(brew、macport等),或者使用rvm pkg install openssl并让rvm管理其路径(你已经有了rvm)。之后,你需要重新安装ruby。RVM指南在这里

0

你不需要使用 sudo。sudo 仅用于执行多用户安装,仅在初始安装期间使用,并将您的用户添加到 rvm 组中(如果安装程序没有为您执行此操作,则通常表示您最初的安装有误)


0

我解决了!

首先,我按照一些答案的建议删除了所有与RVM相关的内容。然后重新启动电脑,从Xcode(Xcode-偏好设置-下载)安装了最新版本的Xcode和命令行工具。再次重启电脑,最终使用了RailsInstaller。一旦我使用它,Rails就回来了,世界上一切都很好。谢谢大家的帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接