无法安装gem,因为“未定义的方法`invoke_with_build_args'代表nil:NilClass”

时间:2014-04-28 20:16:06

标签: ruby-on-rails ruby macos openssl

我在Ruby轨道上,我正处于Ruby on Rails的安装过程中。

我正在尝试安装宝石,但它没有发生,我不知道为什么以及如何解决它。

$gem install bundler

ERROR:  Loading command: install (LoadError)
dlopen(/Users/nthulanemakgato/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-    darwin13.0/openssl.bundle, 9): Library not loaded:     /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /Users/nthulanemakgato/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-    darwin13.0/openssl.bundle
  Reason: image not found -     /Users/nthulanemakgato/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
ERROR:  While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

以下是我尝试过的解决方案之一:

$CONFIGURE_OPTS="--with-openssl-dir=brew --prefix openssl" rbenv install 2.1.1

rbenv: /Users/nthulanemakgato/.rbenv/versions/2.1.1 already exists
continue with installation? (y/N) y
Downloading yaml-0.1.6.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/5fe00cda18ca5daeb43762b80c38e06e
Installing yaml-0.1.6...

BUILD FAILED

Inspect or clean up the working tree at     /var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby-build.20140429120202.53716
Results logged to /var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby-    build.20140429120202.53716.log

Last 10 log lines:
x yaml-0.1.6/win32/vc6/test_reader.dsp
x yaml-0.1.6/win32/vc6/run_loader.dsp
x yaml-0.1.6/win32/vc6/run_parser.dsp
x yaml-0.1.6/win32/vc6/example_reformatter_alt.dsp
x yaml-0.1.6/win32/vc6/example_deconstructor.dsp
x yaml-0.1.6/win32/vc6/libyaml.dsw
x yaml-0.1.6/win32/vc6/yaml.dsp
/var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby-build.20140429120202.53716/yaml-  0.1.6 /var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby-build.20140429120202.53716 ~
configure: WARNING: unrecognized options: --with-openssl-dir
configure: error: expected an absolute directory name for --prefix: openssl

BUILD FAILED

Inspect or clean up the working tree at     /var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby-build.20140429120202.53716
Results logged to /var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby-  build.20140429120202.53716.log

Last 10 log lines:
x yaml-0.1.6/win32/vc6/run_loader.dsp
x yaml-0.1.6/win32/vc6/run_parser.dsp
x yaml-0.1.6/win32/vc6/example_reformatter_alt.dsp
x yaml-0.1.6/win32/vc6/example_deconstructor.dsp
x yaml-0.1.6/win32/vc6/libyaml.dsw
x yaml-0.1.6/win32/vc6/yaml.dsp
/var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby-build.20140429120202.53716/yaml-        0.1.6 /var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby-build.20140429120202.53716 ~
configure: WARNING: unrecognized options: --with-openssl-dir
configure: error: expected an absolute directory name for --prefix: openssl
make: *** No targets specified and no makefile found.  Stop.

我安装了openssl-1.0.1g

我正在使用Mac 10.9.2
ruby 2.1.1p76(2014-02-24修订版45161)[x86_64-darwin13.0]
rbenv 0.4.0-97-gfe0b243

这与其他问题不同,我正在使用rbenv,而其他人则问rvm相关的问题我不能使用。

提前致谢。

4 个答案:

答案 0 :(得分:5)

我发现虽然我已经安装了openSSL,但在识别之前我需要brew upgrade ruby。另一个迷人的小曲子,都是一样的。

答案 1 :(得分:4)

看起来您需要先安装OpenSSL。 所以尝试安装它:

  

$ brew install openssl

然后你需要用OpenSSL重新编译ruby:

  

$ CONFIGURE_OPTS =" - with-openssl-dir = brew --prefix openssl" rbenv install 2.1.1-p76

答案 2 :(得分:0)

当我检查我的

rbenv local

rbenv global 

我们与众不同。

所以我设置了

rbenv local 2.6.5

它解决了我的问题

答案 3 :(得分:-1)

尝试在cmd中使用此代码

chcp 1252