我在Mac上并试图找出如何将我的ruby从2.1.1升级到2.1.7。
我不断收到我无法弄清楚的错误。
当我试图弄清楚Homebrew是否在我的Mac上时,我试试:
which brew
这给出了:
/usr/local/bin/brew
然后我尝试: MJ-2:〜m $ brew医生
我得到了:
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0
MJ-2:~ m$
我尝试使用rvm升级为:
rvm install ruby 2.1.7
我得到了:
Warning! PATH is not properly set up, '/Users/m/.rvm/gems/ruby-2.0.0-p247/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.0.0-p247'.
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-2.1.7.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx_brew.
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0
ERROR: '/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.
然后我尝试:
rvm get stable --auto-dotfiles
我得到了一大堆错误,主要是说:
scripts/functions/support: Can't unlink already-existing object
结束时:
tar: Error exit delayed from previous errors.
Could not extract RVM sources.
Could not update RVM, get some help at #rvm IRC channel at freenode servers.
我无法理解什么是错的。似乎HomeBrew不再在我的Mac上了,或者至少它在我的mac上无法识别(虽然哪个brew有文件路径)并且我似乎也无法使用rvm install命令。
如何在Mac上从终端升级我的ruby版本?
答案 0 :(得分:1)
尝试以下解决步骤,它对我有用。
首先检查/ usr / local目录的所有者。它应该由您的用户名拥有。如果没有运行以下命令。
$ sudo chown -R `whoami` /usr/local
重置您的Homebrew HEAD
$ cd /usr/local
$ git reset --hard FETCH_HEAD
现在更新并升级您的啤酒。
$ brew update && brew upgrade
执行此命令后,您的brew安装已修复,您应该可以使用brew安装新的包。
此后可能还有一个挑战。某些运行良好的软件包可能会出错。你会得到“dyld:Library not loaded:”错误。这意味着缺少该安装的依赖性或需要升级。您需要安装缺少的软件包并重新安装软件包。
示例错误和修复:
$ ruby -v
dyld: Library not loaded: /usr/local/lib/libgmp.10.dylib
Referenced from: /Users/claretrembath/.rvm/rubies/ruby-2.1.3/bin/ruby
Reason: image not found
Trace/BPT trap: 5
错误说,无法加载“libgmp”。你可以在brew中找到和libgmp包并安装它。下面的命令应该解决问题。
$ brew install gmp && rvm reinstall 2.1.7