I'm not able to install json gem on my M1 MacBook. This is the command I'm running.
sudo gem install json -v '2.6.2'
This is the error I'm getting. I'm guessing it because it's picking up Xcode 14.1 Beta 3, but I'm not sure how to have it use a different version of Xcode or if that's the problem.
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.6.2/ext/json/ext/generator
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20221018-37799-1wcwkww.rb extconf.rb
creating Makefile
current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.6.2/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.6.2/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
In file included from ./../fbuffer/fbuffer.h:5:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks')
1 error generated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/json-2.6.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/json-2.6.2/gem_make.out
The issue here is:
Assuming you're trying to install a modern 2.x version of JSON, this error is because it can't see the ruby development tools.
This is because MacOS doesn't include ruby development tools for its base-level version of ruby. That version of ruby is used for some very core-level things on Mac and they lock it down pretty intensely.
The solution is to use rbenv to install a new, user-controlled copy of ruby. This answer has a good step-by-step of how to do that, but the TLDR; is get brew, run brew install rbenv ruby-build, and then run rbenv install 2.6.10 && rbenv global 2.6.10 && rbenv rehash. Then restart your terminal.
Now gem install commands should target the copy of ruby you just installed. (You can validate this by running ruby --version and making sure it lists the version you installed in step 3.) This should fix your issue installing json, whether via gem install or bundle install.
resolved by CocoaPods/CocoaPods#10286
curl -sSL https://get.rvm.io | bash -s stable
close and reopen terminal
rvm install ruby#latest
rvm use ruby-3.0.0 --default
This issue was already reported here, https://github.com/rubygems/bundler/issues/4462.
Can you try bundle update && bundle install.
bundle update will install all of your dependencies, but if you dont want to update all dependencies, try bundle update json only.
Related
I tried changing the gemfile to use a newer version of nokogiri as well as resolve dependencies by brew installing libxml2 and libslt, but nothing worked. Here is the error message:
gumbo.c:32:10: fatal error: 'gumbo.h' file not found
#include "gumbo.h"
^~~~~~~~~
1 warning and 1 error generated.
make: *** [gumbo.o] Error 1
I had the same issue. Not a satisfying answer, but I uninstalled everything and did a clean install using rbenv and it worked.
I had a similar problem. After reading the nokogiri installation instructions, I learned something!
Nokogiri provides precompiled binaries for most things. Now if you switch from Mac to Linux or vice versa, your Gemfile.lock may have a platform list which doesn't include your current platform.
The command that fixed it for me was
bundle lock --add-platform arm64-darwin
Then, bundle just downloaded the precompiled version.
My recommendation is to work out how to install the precompiled version for your platform. When I ran gem install nokogiri that is what happened, but because of the platform list in the Gemfile.lock it wasn't doing that and instead wanted to compile it.
The solution for me on my M1 Macbook was by using rbenv but first:
Uninstall bundler: gem uninstall bundler
Uninstall rbenv: rbenv uninstall YourRubyVersion and then brew uninstall rbenv
(YourRubyVersion you can find it by executing ruby -v)
Delete the Gemfile.lock file.
After that:
brew install rbenv
rbenv install RubyVersion
rbenv init
rbenv global RubyVersion
bundle install
I use github+jekyll to build blog, i try to install jekyll to local(windows 10), while it failed when i rungem install jekyll and the stack trace is
C:\Developments\FrontEnd\rubygems-2.7.7>gem install jekyll
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: C:/Developments/FrontEnd/Ruby25-x64/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
C:/Developments/FrontEnd/Ruby25-x64/bin/ruby.exe -r ./siteconf20180806-33956-l8y76h.rb extconf.rb
creating Makefile
current directory: C:/Developments/FrontEnd/Ruby25-x64/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR=" clean
'make' is not recognized as an internal or external command,
operable program or batch file.
current directory: C:/Developments/FrontEnd/Ruby25-x64/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR="
'make' is not recognized as an internal or external command,
operable program or batch file.
make failed, exit code 1
what i do is:
1. install ruby, path variable was set, version: ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32].
2. install rubygems, version: 2.7.7.
3. install MSYS2.
4. install jekyll, gem install jekyll, then the above error occurs and i'm not sure the reason.
i have tried to install devkit and it not works, i think my ruby version is 2.5+, so don't need devkit and i have uninstalled it.
Anyone could help me?
Although they made the Ruby+DevKit an "optional" download for the RubyInstaller on Windows, if you plan to install gems, it is practically a necessity. A large percentage of the most popular gems are C extension that will need built on your machine when being installed.
The DevKit is a handy toolchain that supplies everything you need for this to be done, automatically without you needed to do anything more than type gem install XXXXX. Without it, you either cannot use C extension gems, or must have already installed MSYS and MingW, have them configured properly, which is all not a user-friendly experience, even for those who familiar with the process.
So even if DevKit is optional, it is still required to make the most of Ruby on Windows.
Solution re-install ruby with rubyinstaller-devkit-2.5.5-1-x64
and issue
gem install bundler
gem install jekyll
I got the same error message. It turned out that the culprit was the ffi gem. I got it to work using this solution.
I had the same issue. I was able to resolve it (in Windows 11 x64) via:
winget install -e --id RubyInstallerTeam.RubyWithDevKit
(I.e., reinstall Ruby with the DevKit)
When I run $ jekyllor $ jekyll serve it raises the following error:
-bash: /usr/local/bin/jekyll: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby: bad interpreter: No such file or directory
I checked /System/Library/Frameworks/Ruby.framework/Versions/ and Version 2.0 does not exist. It turns out that on the same day I updated on HighSierra, Version 2.3 was installed.
I think Jekyll still looks for Version 2.0. So how can I tell Jekyll to use Ruby 2.3?
Edit:
When I uninstall and then install jekyll, it fails:
$ gem install jekyll
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20171111-1004-fgop80.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/ffi-1.9.18/gem_make.out
Solution:
I googled can't find header files for ruby and it turned out that "Command Line Tools for Xcode" must be installed which you can download here: https://developer.apple.com/download/more/
However, I have macOS 10.13 and there is no command line tools for Xcode 8.x (which was the latest version I could install). That's why I searched for Xcode in the Mac App Store and installed Xcode 9. Once, it was installed, a window popped up that said "git requires command line tools. Do you want to install it?". I clicked install and still failed to run $gem install jekyll.
Then I tried $ brew doctor. There were some warnings which I fixed one by one and finally I'm able to run $ gem install jekyll.
I had the same issue. I just uninstalled jekyll
gem uninstall jekyll
and then installed it again.
gem install jekyll
Then it worked again.
I'm failing to install Jekyll using gem in Ruby. Here's the output messages:
D:\Ruby21\bin>gem install jekyll
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
D:/Ruby21/bin/ruby.exe extconf.rb
creating Makefile
make "DESTDIR=" clean
Makefile:238: *** multiple target patterns. Stop.
make "DESTDIR="
Makefile:238: *** multiple target patterns. Stop.
make failed, exit code 2
Gem files will remain installed in D:/Ruby21/lib/ruby/gems/2.1.0/gems/redcarpet-3.2.0 for inspection.
Results logged to D:/Ruby21/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/redcarpet-3.2.0/gem_make.out
D:\Ruby21\bin>
Unlike the other issue here, where the error breaks in the Makefile on line 222, mine breaks in the Makefile on line 238.
I can tell it has nothing to do with spaces in my installation path (since I installed Ruby in the root of my D drive). But anything from there is beyond my scope.
I'm using Windows Vista x86. I have installed Ruby 2.1.0 stable.
Does anyone know how to fix this?
Nevermind, I didn't solve the problem, but rather I used a workaround.
I installed Cygwin-x86 on my laptop, then installed Ruby and Rubygem, finally installed Jekyll and managed to go past the redcarpet-v3.2.0 build error.
To install Jekyll in Cygwin:
Run cygwin-setup.exe.
Install appropriate packages: Ruby, rubygem, make, gcc, git, libxslt, libxml2. Some more packages may be required here.
Install jekyll using gem install jekyll. Wait.
Type in command: vim ~/.bashrc
Scroll to the end and add export PATH=$PATH:".gem/ruby/gems/jekyll-2.4.0/bin"
That's how the Jekyll is installed on Cygwin.
Later on, you may need the following:
Subversion
bzip2
apt-cyg
patch
curl
rvm
jemoji
jekyll-sitemap
And have to do a lot of ~/.bashrc editing, calling source $HOME/path/to/rvm and PATH fixing.
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)
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.
One-liner to fix that
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
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
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.
#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
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
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.
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
None of these worked for me.
What finally worked is running the command with a sudo -
gem install byebug -v '9.0.6'
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!
I used a simple solution... install through brew
brew install name