I am running into some trouble installing Ruby 2.2.2 on macOS Big Sur. Has anyone had a similar issue that they were able to resolve? Many thanks 🙏
Error:
`Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/findum/.rbenv/versions/2.2.2
Downloading ruby-2.2.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.bz2
Installing ruby-2.2.2...
WARNING: ruby-2.2.2 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
BUILD FAILED (macOS 11.1 using ruby-build 20201225)
Inspect or clean up the working tree at /var/folders/x8/g8yqvrh55gq0wds4hny1t94r0000gn/T/ruby-build.20210101111906.42540.uFRvAN
Results logged to /var/folders/x8/g8yqvrh55gq0wds4hny1t94r0000gn/T/ruby-build.20210101111906.42540.log
Last 10 log lines:
compiling ../.././ext/psych/yaml/parser.c
linking shared-object json/ext/parser.bundle
linking shared-object pathname.bundle
installing default psych libraries
linking shared-object json/ext/generator.bundle
linking shared-object bigdecimal.bundle
linking shared-object psych.bundle
linking shared-object nkf.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2`
EDIT
It looks like OP edited the error in the original message so the below answer is no longer relevant. Leaving it here for posterity.
Updated Answer
Based on discussion in a couple of Github issues on the rbenv repo,
https://github.com/rbenv/ruby-build/issues/1480
https://github.com/rbenv/ruby-build/issues/1489
it sounds like Apple changed the default CFLAGS as part of xcode 12, which makes some of the native extension installations go haywire. It sounds like the solution proposed in those issues is
CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.2.2
Original answer
The error states it failed due to issues with extensions
The Ruby readline extension was not compiled.
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
so I would suggest trying to install those extensions manually first, then retrying the ruby install.
With brew:
brew install readline
brew install zlib
There are some issues on ruby-build's github that might help as well:
https://github.com/rbenv/ruby-build/issues/1076
https://github.com/rbenv/ruby-build/issues/832#issuecomment-160906530
Related
I am encountered a gem install error in CentOS6.7
But when I use gcc -version it show the version of gcc is 4.4.7.
Here is the error information:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb creating Makefile Compiling v8 for ia32
Using python 2.6.6 Using compiler: /usr/bin/c++ (GCC version
1.5.0) Unable to find a compiler officially supported by v8. It is recommended to use GCC v4.4 or higher
/home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/libv8-3.16.14.7/ext/libv8/builder.rb:28:in
make_flags': undefined method include?' for nil:NilClass
(NoMethodError)
from /home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/libv8-3.16.14.7/ext/libv8/builder.rb:56:in
block in build_libv8!'
from /home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/libv8-3.16.14.7/ext/libv8/builder.rb:49:in
chdir'
from /home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/libv8-3.16.14.7/ext/libv8/builder.rb:49:in
build_libv8!'
from /home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/libv8-3.16.14.7/ext/libv8/location.rb:24:in
install!'
from extconf.rb:7:in '
libv8 maintainer here.
Could you please try again after updating libv8 to the latest 3.16 version available?
If you continue receiving an error, please consider opening an issue with more info about your system and the gcc --version output of your compiler in libv8's issue tracker: https://github.com/cowboyd/libv8/issues
As a side note, you should consider asking the maintainers of a project directly first, through their issue tracker for example, before shooting a question in SO. Your question probably would have remained unanswered had I not been by chance looking for recent questions about libv8 here.
I try to install pushmeup plugin for phonegap push notifications (ios).
When I run command sudo gem install pushmeup I get this error:
Building native extensions. This could take a while... ERROR: Error
installing pushmeup: 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
/Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection. Results
logged to
/Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/json-1.8.1/gem_make.out
GitHub:
https://github.com/phonegap-build/PushPlugin
Params:
ruby -v ruby 2.0.0p247 (2013-06-27 revision 41674)
[universal.x86_64-darwin13]
gem -v
2.2.2
Mac OS X v 10.9.2
XCode Version 5.1 (5B130a)
cordova -v
3.4.0-0.1.3
Apparently Apple broke something on Mavericks, they removed the warning flag unused-command-line-argument-hard-error-in-future acording to this issue: #528
Please try this command:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future sudo gem install pushmeup
what it does? this sets the environment variable: ARCHFLAGS= this adds a ignore warnings -Wno-error= and this is the warning that you don't see in mavericks unused-command-line-argument-hard-error-in-future (which should be ignored)
In Apple documentation:
Compiler
As of Apple LLVM compiler version 5.1 (clang-502) and later, the
optimization level -O4 no longer implies link time optimization (LTO).
In order to build with LTO explicitly use the -flto option in addition
to the optimization level flag. (15633276) 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
Note: This option will not be supported in the future. To workaround
this issue, set the ARCHFLAGS environment variable to downgrade the
error to a warning. For example, you can install a Python native
extension with:
$ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
easy_install ExtensionName
Similarly, you can install a Ruby Gem with:
$ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
gem install GemName 16214764 updated
EDIT HISTORY
just tested on my machine, using same ruby:
$ gem install pushmeup
Fetching: pushmeup-0.1.2.gem (100%)
Successfully installed pushmeup-0.1.2
Parsing documentation for pushmeup-0.1.2
Installing ri documentation for pushmeup-0.1.2
Done installing documentation for pushmeup after 1 seconds
1 gem installed
From what i saw you are not using rvm or rbenv so the problem is not in gcc dependencies
Accordingly to the output provided, the error was when installing json-1.8.1.
Can you post the log located at: /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/json-1.8.1/gem_make.out ?
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
I have burned an embarrassing number of hours trying to install ruby and rails on Mac.
I am using Lion 10.7.2, Xcode 4.2.1, rvm 1.10.0, and gcc 4.2.1
Does anyone have a surefire way to install ruby with rvm. Or, is there
rvm install 1.9.2 -C --with-readline-dir=$rvm_path/usr --with-iconv-dir=$rvm_path/usr
Produces the error
make[1]: *** [../../.ext/x86_64-darwin11.2.0/tcltklib.bundle] Error 1
make: *** [mkmain.sh] Error 1
Running
rvm install 1.9.3-p0 --with-gcc=clang
Produces the error
make: *** [.rbconfig.time] Abort trap: 6
Simply running
rvm install 1.9.3
Produces the error
make[2]: *** [../../.ext/x86_64-darwin11.2.0/tcltklib.bundle] Error 1
make[1]: *** [ext/tk/all] Error 2
make: *** [build-ext] Error 2
From reading this, I ran the below in the Terminal and my Mac would not restart until I put the libiconv.2.dylib back in place using Target Disk Mode.
rm /usr/local/lib/libiconv.2.dylib
ln -s /usr/lib/libiconv.2.dylib /usr/local/lib/libiconv.2.dylib
From this link, I also removed a previous install of Macfuse which is known to cause problems
I have reinstalled Xcode twice [Install Xcode from the Application Folder].
Is there another way to get Ruby Installed on Lion?
Many thanks as I'm fast running out of ideas
Graham
The following worked for me:
$ rvm install 1.9.3 --with-gcc=clang
I got that from this page.
I had this problem too and tried several of the listed solutions unsuccessfully. Then I downloaded XCode 4.3.1 for Lion and the Xcode command line tools update (dated March 7, 2012) from Apple's developer site and just re-ran 'rvm install 1.9.3'. Worked perfectly and installed 1.9.3p125.
Hope this helps
Note that RVM itself tells you that it won't work with XCode 4.2:
** Lion Users: DO NOT use Xcode Version 4.2.x for OS X Lion. It currently fails to build several rubies and gems,
as well as several Homebrew and Macports packages as well. Xcode Version 4.1 (4B110) works.
You can see this warning again by calling rvm requirements.
The simplest (albeit slow) way to fix the problem is to remove XCode 4.2 and download and install XCode 4.1. You can also apparently fix it with a separate gcc-4.2 installation, but I don't know the details of how you'd do that.
For more detail, see the full discussion on the rvm github tracker
I had a similar problem on my 10.7.2 server with Xcode 4.2.1. Installing this stand-alone gcc compiler (sourced from apple), did the trick for me.
You need to force autoconf.
rvm install 1.9.3 --force-autoconf
I was finally able to install ruby by using macports and Xcode 4.2.1. Had to abandon rvm.
port install ruby19 +nosuffix
Thanks for all of the answers and help :)
The following worked for me:
rvm pkg install iconv
rvm pkg install readline
rvm remove 1.9.3
rvm install 1.9.3 --with-iconv-dir=$rvm_path/usr --with-readline-dir=$rvm_path/usr
source: http://blog.merjis.com/2011/12/18/rails-3-1-ruby-1-9-3-lion-xcode-4-1/
I have previously successfully installed the Jekyll gem on a Mac with the gcc compiler that shipped with Xcode 3. Unfortunately I can't install it on a different Mac that now has Xcode 4.1. This Mac used to have Xcode 3, but I uninstalled it using the command sudo /Developer-3.2.5/Library/uninstall-devtools --mode=all.
When trying to sudo gem install jekyll I get the compilation error shown below:
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
creating Makefile
make
gcc -I. -I/usr/local/lib/ruby/1.8/i686-darwin10.3.2 -I/usr/local/lib/ruby/1.8/i686-darwin10.3.2 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -D_XOPEN_SOURCE=1 -fno-common -pipe -fno-common -c porter.c
porter.c:31:44: error: stdlib.h: No such file or directory
porter.c:32:47: error: string.h: No such file or directory
porter.c: In function ‘create_stemmer’:
porter.c:85: warning: incompatible implicit declaration of built-in function ‘malloc’
porter.c: In function ‘setto’:
porter.c:199: warning: incompatible implicit declaration of built-in function ‘memmove’
make: *** [porter.o] Error 1
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/fast-stemmer-1.0.0 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/fast-stemmer-1.0.0/ext/gem_make.out
There seems to be a fairly fundamental problem here! How can I fix this? I'm using Ruby 1.8.7 and RubyGems 1.3.7 1.8.10.
Thanks in advance.
Now this is weird. I reinstalled Xcode 4.1 last night and it's fixed the problem: I can compile the native extensions and install the Jekyll gem.
I was able to reinstall Xcode because according to the Mac App Store it wasn't installed at all, even though I've been happily using it! I think the store must look for the existence of the Install XCode application in the /Applications folder, which I'd deleted because it's just an installer and takes up over 3GB.
Before running gem install jekyll try entering export CC=gcc-4.2 as per: RVM with Lion If this fixes your issue, it's because gems is depending on GCC instead of LLVM, which is now default in 4.1. Add the export CC=gcc-4.2 to your ~/.bashrc file to not have to enter it every time you need to compile gem.
RubyGems 1.3.7 is quite out of date. We're talking about 1.8.9... I suggest you to upgrade it.
I'm using Lion without any issue, but I have to admit I'm not using system Ruby. I installed a different 1.8.7 (and 1.9.2) version using RVM.