在以前的 OS X 版本中,我使用 sudo 安装了我的 gem。对于 Yosemite,我想改变这种情况,不使用 sudo 进行安装。要保留默认 gem,请执行以下操作:
/Library/Ruby/Gems/2.0.0
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
并将我想要安装的放入第三个文件夹
/Users/myuser/.gem/ruby/2.0.0
这三个被列为gem environment
命令返回的 GEM PATHS。安装工作正常。之后,我将路径变量添加到我的 bash_profile 中:
export PATH=~/bin:/usr/local/bin:/Users/myuser/.gem/ruby/2.0.0/bin:$PATH
我已经安装了 Sass、Compass 和其他一些与 Compass 相关的 gem。当我尝试在终端中运行 compass watch 时,我得到了:
[myuser@localhost][project] compass watch
LoadError on line ["55"] of /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb: cannot load such file -- sassy-math
Run with --trace to see the full backtrace
[myuser@localhost][project]
如果尝试从 Codekit 内部运行 Compass,则情况相同。
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'compass' (>= 0) among 12 total gem(s) (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /Users/danton/.gem/ruby/2.0.0/bin/compass:22:in `<main>'
似乎根本没有注意到我的用户文件夹中的 gem。有没有办法让该设置正常运行,还是我必须恢复到 sudo 安装?:/