Rubygems 无法安装在 OS X Lion 上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7454361/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rubygems do not install on OS X Lion
提问by d135-1r43
I used to have no problems at all with ruby, gems and all related stuff. But after installing X Code Developer Tools and upgrading to Lion the gems do not install.
我曾经对 ruby、gems 和所有相关的东西都没有任何问题。但是在安装 X Code Developer Tools 并升级到 Lion 之后,gems 不会安装。
I get the following error for every gem. This is the message for sqlite as an example:
对于每个 gem,我都会收到以下错误。这是以sqlite为例的消息:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
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/sqlite3-1.3.4 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/sqlite3-1.3.4/ext/sqlite3/gem_make.out
What went wrong? How to fix it?
什么地方出了错?如何解决?
回答by shadowhorst
I had to install the Command Line Tools in the latest Xcode-Version (4.3.1) and
我必须在最新的 Xcode 版本 (4.3.1) 和
sudo gem install rails
worked like a charm.
像魅力一样工作。
To install Command Line Tools, go to Xcode Preferences > Downloads or use the following command in terminal (thx @Purell):
要安装命令行工具,请转到 Xcode Preferences > Downloads 或在终端中使用以下命令 (thx @ Purell):
xcode-select --install
回答by David Douglas
I'm using Mavericks and Ruby 2.0.0 and I also got this error (mkmf.rb can't find header files) when installing gems. I solved this issue by creating some symbolic links in Terminal.
我正在使用 Mavericks 和 Ruby 2.0.0,并且在安装 gems 时我也遇到了这个错误(mkmf.rb 找不到头文件)。我通过在终端中创建一些符号链接解决了这个问题。
#First install developer tools again:
xcode-select --install
#Create symbolic link to Ruby include (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include
#Create symbolic link to config.h (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/Headers/ruby/config.h /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h
回答by diham
I faced same problem while trying to install rails on my Lion. This is how i could solve it.
我在尝试在我的 Lion 上安装导轨时遇到了同样的问题。这就是我可以解决的方法。
Install rvm
安装 rvm
$ curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
$ curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
Install osx-gcc-installer
安装 osx-gcc-installer
https://github.com/kennethreitz/osx-gcc-installer
https://github.com/kennethreitz/osx-gcc-installer
Installed new version of ruby
安装了新版本的 ruby
rvm install 1.9.3
rvm install 1.9.3
Typed to following command to show the requirements
键入以下命令以显示要求
rvm requirements
rvm requirements
To use an RVM installed Ruby as default, instead of the system ruby:
要使用 RVM 安装的 Ruby 作为默认值,而不是系统 ruby:
rvm system ; rvm gemset export system.gems ; rvm 1.9.3 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.9.3
rvm system ; rvm gemset export system.gems ; rvm 1.9.3 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.9.3
Installed rails:
安装导轨:
sudo gem install rails
sudo gem install rails
My Mac is now read for rails!! YAY!!
我的 Mac 现在可以读取 Rails 了!!好极了!!
回答by Omaty
While installing Rails I had the error :
安装 Rails 时出现错误:
can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
在 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h 找不到 ruby 的头文件
As i had already Xcode installed, I had just to install Command Line Tools to resolve this problem
因为我已经安装了 Xcode,所以我只需要安装命令行工具来解决这个问题
回答by Thilo
回答by kb1ibt
You need to have XCode installed, it includes ruby.h as well as some other important files needed to compile other native gems.
您需要安装 XCode,它包括 ruby.h 以及编译其他原生 gem 所需的其他一些重要文件。
回答by Joel
Update to the latest version of xcode, that fixed the problem for me. Make sure xcodebuild is in your path.
更新到最新版本的 xcode,为我解决了这个问题。确保 xcodebuild 在您的路径中。
running xcodebuild -version in a terminal window should output 4.2.1 (4.x at least).
在终端窗口中运行 xcodebuild -version 应该输出 4.2.1(至少 4.x)。
回答by robustus
Hello i'm sorry i can't test this answer but i would suggest to change the default search paths in your bashrc and extconf.rb since the Library files seem to be moved in Lion.
您好,很抱歉,我无法测试此答案,但我建议更改 bashrc 和 extconf.rb 中的默认搜索路径,因为库文件似乎已在 Lion 中移动。
(P.S. if he wants to work with the default 1.8 Version, rvm would be an unneeded hassle)
(PS 如果他想使用默认的 1.8 版本,rvm 将是一个不必要的麻烦)
回答by ervi
After a OS-Update make sure that you do accept the X-Code license even when you have used command-line-tools before. Only then some header-files will be available. To accept the license you have to run X-Code once.
操作系统更新后,即使您之前使用过命令行工具,也要确保接受 X-Code 许可。只有这样一些头文件才可用。要接受许可证,您必须运行一次 X-Code。
回答by Julian K
I just forgot to run it with the sudocommand.
我只是忘了用sudo命令运行它。
sudo gem install sqlite3
sudo gem install sqlite3
not:
不是:
gem install sqlite3
gem install sqlite3

