我安装了Ruby v2:
$ ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin11.0]
但是当我运行时,我在多个宝石上出现了这个错误:
$ sudo gem update
问题是什么以及如何解决?
$ gem update
Updating installed gems
Updating actionmailer
Fetching: activesupport-4.1.8.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/1.8 directory.
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/user/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
$ rvm info
-bash: rvm: command not found
答案 0 :(得分:0)
gem env使用的是旧版本的ruby。我通过
完全删除了宝石gem list | cut -d" " -f1 | sudo xargs gem uninstall -aIx
(保持此终端选项卡打开以便您知道您拥有哪些宝石,然后重新安装它们)然后打开一个新的终端选项卡,然后通过执行
删除宝石$ which gem
/usr/bin/gem
$ cd /usr/bin && sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem gem1.8.7 && sudo rm gem
如果我想稍后使用它,我会将gem符号化为gem1.8.7。
然后我按照这里的方向https://rubygems.org/pages/download重新安装了宝石,使用最新的ruby版本,在我的例子中是Ruby 2.1.2p95。