Ruby Gem 在 Mavericks 和 Xcode 5.1 上安装 Json 失败 - 未知参数:'-multiply_definedsuppress'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22352838/
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
Ruby Gem install Json fails on Mavericks and Xcode 5.1 - unknown argument: '-multiply_definedsuppress'
提问by g8M
I was trying run gem install json and got the following error
我正在尝试运行 gem install json 并收到以下错误
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [generator.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /opt/boxen/repo/.bundle/ruby/2.0.0/gems/json-1.8.0 for inspection.
Results logged to /opt/boxen/repo/.bundle/ruby/2.0.0/extensions/universal-darwin-13/2.0.0/json-1.8.0/gem_make.out
I'm using:
我正在使用:
Os X: 10.9.2
Xcode: 5.1 Build version 5B130a
Command Line Tools (CLT): 5.1.0.0.1.1393561416
Ruby: ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
Ruby Gem: 2.2.2
GCC: 4.2.1 Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
操作系统X:10.9.2 Xcode:5.1 构建版本 5B130a
命令行工具 (CLT):5.1.0.0.1.1393561416
Ruby:ruby 2.0.0p247(2013-06-27 修订版 41674)[universal]Gem632.x28
Ruby。 .2
GCC:4.2.1 Apple LLVM 5.1 版 (clang-503.0.38)(基于 LLVM 3.4svn)
回答by Kasper Munck
I am encountering the exact same problem after updating Xcode to 5.1 and news from Apple aren't good. From Xcode 5.1 Release Notes:
将 Xcode 更新到 5.1 后,我遇到了完全相同的问题,而 Apple 的消息并不好。来自Xcode 5.1 发行说明:
- The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.
Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning:
-Wno-error=unused-command-line-argument-hard-error-in-futureTo workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning.
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
- Xcode 5.1 中的 Apple LLVM 编译器将无法识别的命令行选项视为错误。在构建 Python 本机扩展和 Ruby Gems 时已发现此问题,其中当前指定了一些无效的编译器选项。
使用无效编译器选项的项目需要更改以删除这些选项。为了帮助缓解这种转变,编译器将暂时接受一个选项,将错误降级为警告:
-Wno-error=unused-command-line-argument-hard-error-in-future要解决此问题,请设置 ARCHFLAGS 环境变量以将错误降级为警告。
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
It seems that all gems violating the compiler options must be updated to use valid options. It is explicitly stated that: This option [downgrading error to warning] will not be supported in the future.
似乎所有违反编译器选项的 gem 都必须更新以使用有效的选项。明确声明:该选项【降级错误到警告】以后将不再支持。
The clang note we are seeing (this will be a hard error (cannot be downgraded to a warning) in the future) corresponds to the change announced in the release notes.
我们看到的 clang 说明(这将是未来的硬错误(不能降级为警告))对应于发行说明中宣布的更改。
To answer your question specifically, use the following to install the json gem:
要专门回答您的问题,请使用以下命令安装 json gem:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install json
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install json
Note, however, that this is only a temporary fix.
但是请注意,这只是临时修复。
回答by Paul Brit
One-liner to fix that
One-liner 来解决这个问题
curl https://gist.githubusercontent.com/Paulche/9713531/raw/1e57fbb440d36ca5607d1739cc6151f373b234b6/gistfile1.txt | sudo patch /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/rbconfig.rb
回答by Sbhklr
To address the issue you can install the most recent version of ruby as described by @Sash. You can use the following commands to do so. In case you already have installed rvm, you don't need to reinstall it.
要解决此问题,您可以按照@Sash 的描述安装最新版本的 ruby。您可以使用以下命令来执行此操作。如果您已经安装了 rvm,则无需重新安装它。
#Install rvm
\curl -sSL https://get.rvm.io | bash -s stable
#Install ruby version 2.0.0-p451
rvm install ruby-2.0.0-p451
#Print ruby version to verify that it was installed successfully
ruby -v
#Install json gem
sudo gem install json
回答by Shahar Hadas
Issue already addressed by Ruby:
Ruby 已经解决的问题:
https://bugs.ruby-lang.org/issues/9624
https://bugs.ruby-lang.org/issues/9624
now we just need to wait for Apple to update their ruby version (2.0.0p247) to the one after the latest one (2.0.0p451) which hasn't come out yet ... (or brew/macport it)
现在我们只需要等待Apple将他们的ruby版本(2.0.0p247)更新到尚未发布的最新版本(2.0.0p451)之后的版本......(或brew / macport)
Update (2014-05-15): Mavericks 10.9.3 updates ruby to
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
And this seems to resolves the issue.
更新 (2014-05-15):Mavericks 10.9.3 将 ruby 更新为
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
并且这似乎解决了问题。
回答by worldask
@Muncken has already provided an answer to install gem one by one:
@Muncken 已经一一提供了安装 gem 的答案:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
Base on Muncken's answer, I've tried that it also works when using bundle install
基于芒肯的回答,我试过它在使用时也有效 bundle install
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future bundle install
回答by xbeta
In my case, I actually have similar problem, but not on the system ruby, but on rubies installed by rvm from OSX 10.8, and it has issues after upgrading to OSX 10.9.
就我而言,我实际上有类似的问题,但不是在系统 ruby 上,而是在 rvm 从 OSX 10.8 安装的 rubies 上,并且在升级到 OSX 10.9 后出现问题。
A simple reinstall works: rvm reinstall ruby-2.1.1
一个简单的重新安装工作: rvm reinstall ruby-2.1.1
回答by xbeta
On OSX 10.10, I had several issues when running rails new firstappsuch as:
在 OSX 10.10 上,我在运行时遇到了几个问题,rails new firstapp例如:
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
fatal error: 'ruby/config.h' file not found
I updated rvm with this configuration and all the errors are gone!:
我用这个配置更新了 rvm,所有的错误都消失了!:
rvm get stable --auto-dotfiles
You can tell from the app name that I just started fiddling with Ruby on Rails, so the above advice may or may not work for you.
您可以从应用程序名称看出我刚刚开始使用 Ruby on Rails,因此上述建议可能适合您,也可能不适合您。
回答by Mark
Paul Chechetin's one-liner doesn't appear to work anymore (9/21/15). However, this replyto the post mentioned in Pete's reply solved the problem for me:
Paul Chechetin 的单线似乎不再起作用(2015 年 9 月 21 日)。然而,这个回答在皮特的答复中提到后解决了这个问题对我来说:
- (a) Install Apple's XCode, then (b) launch it and accept the licensing terms (I had done (a), but not (b).)
sudo gem uninstall compasssudo gem install compass
- (a) 安装 Apple 的 XCode,然后 (b) 启动它并接受许可条款(我已经完成了 (a),但没有完成 (b)。)
sudo gem uninstall compasssudo gem install compass
回答by Alex Jose
None of these worked for me.
这些都不适合我。
What finally worked is running the command with a sudo -
最终起作用的是使用 sudo 运行命令 -
gem install byebug -v '9.0.6'
gem install byebug -v '9.0.6'
回答by user3800976
I used a simple solution... install through brew
我使用了一个简单的解决方案...通过 brew 安装
brew install name
brew 安装名称

