Ruby Gem install Json fails on Mavericks and Xcode 5.1 - unknown argument: '-multiply_definedsuppress'
Asked Answered
M

11

107

I was trying run gem install json and got the following error

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)

Macymad answered 12/3, 2014 at 13:19 Comment(4)
I did lots of stuff trying to solve this problem and I don't know exactly which solved but I installed the new ruby version, downloaded previous version of Command Line Tools (Late October) and executed the command @Muncken 's answer (ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future {original command}). That solved my problem. In my specific case I was using boxen to install my environment so the final command I used was ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future /opt/boxen/repo/script/boxen --no-fde. Thanks everyone that helped.Macymad
Mavericks 10.9.3 updates ruby to: ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13] This seems to resolves the issue.Cluster
The issue is with old version of ruby like @Sash says. I had to update to 2.0.0p451 manually from 2.0.0p2.. using rvm: rvm install ruby-2.0.0-p451. rvm should set it as default version then you just need to reinstall your gemsLetourneau
I'm having this issue with rvm ruby 2.2.0p0 (2014-12-25 revision 49005)Disinterested
H
146

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:

  • 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-future

To 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

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.

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.


To answer your question specifically, use the following to install the json gem:

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install json

Note, however, that this is only a temporary fix.

Hummer answered 12/3, 2014 at 15:15 Comment(9)
Thank you so much, you've helped me a lot. Since the update to Xcode CLI tools 5.1 version I was getting a shitload of errors when trying to bundle a Rails 4 project. Though I needed to pass the ARCHFLAGS twice: when installing specific corrupted gems and when running Bundler.Sectional
Glad I could help Rafael. I've spent most of my day in the same mess.Hummer
I did lots of stuff trying to solve this problem and I don't know exactly which solved but I installed the new ruby version, downloaded previous version of Command Line Tools (Late October) and executed the command on this answer. This solved my problems. In my case I was using boxes to install my environment so the final command I used was ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future /opt/boxen/repo/script/boxen --no-fde. Thanks everyone that helpedMacymad
This solution also works when installing the Fontcustom gem on OSX Mavericks.Immure
I can’t get this solution working for me. Still fails with clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future] Any ideas?Spew
You could try exporting explicitly export ARCHFLAGS="...", then running your compile command in a new line, such as gem install json (I'm compiling Python modules myself). By the way don't forget to add previously existing archflags to the line, or else they will be overwritten.Syncretize
If you are still having trouble with this answer you may need to sudo gem install bundler on your Mac. I found setting the env and using bundler 1.6.2 to be the only combination to work well.Gave
This also works to install bcrypt-ruby on Mavericks using Bundler.Swaine
It worked for me, but I had to run it for each dependency that had the problem.Picardi
S
107

One-liner to fix that

curl https://gist.githubusercontent.com/pbrit/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
Samul answered 22/3, 2014 at 20:18 Comment(1)
Didn't work. Ran the command and had failures: patching file /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin15/rbconfig.rb Hunk #1 FAILED at 82. Hunk #2 FAILED at 125. 2 out of 2 hunks FAILED -- saving rejects to file /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin15/rbconfig.rb.rejCarpo
R
19

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.

#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
Rimini answered 13/3, 2014 at 16:15 Comment(0)
C
12

Issue already addressed by Ruby:

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)

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.

Cluster answered 12/3, 2014 at 21:3 Comment(0)
R
4

@Muncken has already provided an answer to install gem one by one:

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

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future bundle install
Rattly answered 27/3, 2014 at 2:18 Comment(5)
Could you give a description?Halfpenny
like @Muncken said, but he just provided the answer gem install, I tried that bundle install also worksRattly
Your answer should be complete on it's own, even without context of other answers.Halfpenny
Yup. Much better and complete.Halfpenny
This ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future can be used in every command that fails with clang: error: unknown argument: '-multiply_definedsuppress'. Actually this tells the clang compiler that this error should be treated as warningMacymad
A
2

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.

A simple reinstall works: rvm reinstall ruby-2.1.1

Abrogate answered 10/4, 2014 at 7:12 Comment(1)
After trying everything under the sun to fix this issue, this is what did it for me! Thank you!Abilene
I
1

On OSX 10.10, I had several issues when running rails new firstapp such as:

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 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.

Intramolecular answered 31/8, 2014 at 0:5 Comment(0)
S
1

Paul Chechetin's one-liner doesn't appear to work anymore (9/21/15). However, this reply to the post mentioned in Pete's reply solved the problem for me:

  • (a) Install Apple's XCode, then (b) launch it and accept the licensing terms (I had done (a), but not (b).)
  • sudo gem uninstall compass
  • sudo gem install compass
Samuelsamuela answered 21/9, 2015 at 22:56 Comment(1)
I had updated Xcode but had never launched it. When I launched it, it prompted me to accept something, then it had to "install components." After that, I tried my gem install json again and it worked!Idaliaidalina
G
1

None of these worked for me.

What finally worked is running the command with a sudo -

gem install byebug -v '9.0.6'

Garek answered 19/4, 2017 at 6:7 Comment(0)
Z
1

It's been a while and I've got similar error. An alternative to folks using bundler is to add the flag to the build configuration like below example:

bundle config build.<gemname> --with-cflags="-Wno-error=implicit-function-declaration"

followed by

bundle install

Please note that you must replace <gemname> above with the name of the actual gem that is throwing the error while building native extensions.

I hope this becomes helpful to others that face similar issues in the future!

Zedoary answered 5/11, 2020 at 0:33 Comment(0)
B
-2

I used a simple solution... install through brew

brew install name

Basrelief answered 25/9, 2014 at 15:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.