我最近买了一个 macbook pro 并下载了 Mac OS 山狮。有人告诉我 ruby 已经预先安装,要下载 rails,我会输入:
$ sudo gem install rails
但是,当我这样做时,我收到此错误:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.7.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
我在 stackoverflow 上寻找答案并尝试下载 Xcode 4.4.1 版,但$ sudo gem install rails
仍然无法正常工作。另外,当我尝试不带 sudo 的命令时,它会告诉我:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
有解决这个问题的方法吗?其他人提到了一个叫做 rvm 的东西,但我真的不知道那是什么或如何使用它。