我运行brew update
和brew upgrade rbenv ruby-build
。仅供参考:我昨天将xcode更新到8.1版。
我查看了可用的版本rbenv install -l
。
然后我尝试按rbenv install 2.2.5
安装ruby2.2.5,然后我收到以下错误。
我试过2.3.1但是我得到了同样的错误。我该如何解决这个问题?
Downloading ruby-2.2.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.5.tar.bz2
Installing ruby-2.2.5...
BUILD FAILED (OS X 10.11.6 using ruby-build 20160602)
Inspect or clean up the working tree at /var/folders/2p/49l6q0gs6qzgtxbg4h1st_5h0000gq/T/ruby-build.20161106122840.51330
Results logged to /var/folders/2p/49l6q0gs6qzgtxbg4h1st_5h0000gq/T/ruby-build.20161106122840.51330.log
Last 10 log lines:
Referenced from: /private/var/folders/2p/49l6q0gs6qzgtxbg4h1st_5h0000gq/T/ruby-build.20161106122840.51330/ruby-2.2.5/./miniruby (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _clock_gettime
Referenced from: /private/var/folders/2p/49l6q0gs6qzgtxbg4h1st_5h0000gq/T/ruby-build.20161106122840.51330/ruby-2.2.5/./miniruby (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
make: *** [encdb.h] Trace/BPT trap: 5
make: *** Waiting for unfinished jobs....
make: *** [.rbconfig.time] Trace/BPT trap: 5
答案 0 :(得分:1)
首先,我已经卸载了所有内容:
brew uninstall rbenv ruby-build
由于旧的粘性ruby-build安装,我强迫这样:
brew uninstall --force ruby-build
当我输入ruby -v
时,我可以看到对rbenv的旧调用。所以我从$HOME/.bash_profile
删除所有rbenv引用,然后用:
source $HOME/.bash_profile
现在我只看到旧的默认MacOs ruby版本:
ruby -v # ruby 2.0.0p481 (2014-05-08 revision 45883)
which ruby # /usr/bin/ruby
?好!现在是时候再次安装它们然后列出可用的Ruby版本:
brew install rbenv
rbenv install -l
我现在可以看到更多的Ruby选项来安装......
2.2.4,2.2.5,2.2.6,2.2.7,2.2.8,2.2.9,2.3.0,2.3.1,2.3.2,2.3.3,2.3.4,2.3.5 ,2.3.6,2.4.0,2.4.1,2.4.2,2.4.3,2.5.0
我将选择其中一个并使其成为全球性的:
rbenv install 2.5.0
rbenv global 2.5.0
我的情况是你还没有$HOME/.bash_profile
rbenv配置行,运行:
rbenv init
...并将结果行添加到$HOME/.bash_profile
。
答案 1 :(得分:0)
我尝试升级rbenv。
brew upgrade rbenv
然后我收到了警告。
Warning: You have Xcode 8 installed without the CLT;
this causes certain builds to fail on OS X El Capitan (10.11).
Please install the CLT via:
sudo xcode-select --install
Error: rbenv 1.0.0 already installed
所以我安装了xcode-select
。
sudo xcode-select --install
然后我尝试升级rbenv但已经安装了rbenv 1.0.0。
brew upgrade rbenv
Error: rbenv 1.0.0 already installed
所以我尝试安装2.3.1和2.2.5
rbenv install 2.3.1
...
rbenv install 2.2.5
这是成功的。
➜ ~ rbenv versions
system
1.9.3-p327
* 2.2.2 (set by /Users/sokada/.rbenv/version)
2.2.5
2.3.1
我还需要安装捆绑包,因为我使用捆绑包来解决这个问题。
gem install bundler -v 1.13.6 // newest as of this writing
bundler -v
bundler install // finally I could use it.
答案 2 :(得分:0)
这是一个非常老的问题。但是,我认为正确的方法是升级ruby-build
。它可以作为提供rbenv install命令的rbenv插件使用。
因此,请按照以下方法解决此问题:https://github.com/rbenv/ruby-build#upgrading
# Via Homebrew
$ brew update && brew upgrade ruby-build