A recent OpenSSL update on ArchLinux broke Ruby because the latter depends on SSLv3 being supported by the former. Ruby code that uses OpenSSL will reveal the problem when they terminate with an error like the below:
openssl.so: undefined symbol: SSLv3_method - .../openssl.so (LoadError)
I use multiple versions of Ruby with RVM and the problem aplies to all of them.
The OpenSSL version I have the problem with is 1.0.2h but I believe it was introduced with 1.0.2g. Version 1.0.2f works fine.
How can this be compatibility issue be overcome (without downgradng OpenSSL) ?
The problem is caused by the ArchLinux OpenSSL package being built without SSLv3 support, as of this commit. I believe that a similar thing has been done in other distros such as Ubuntu.
The solution in a RVM environment is to reinstall your Rubies which will rebuild them (you may also wish to update to the latest rvm):
$ rvm get head # optional, if you want to!
$ rvm reinstall all # or a specifc ruby version instead of 'all'
However, older rubies will still fail with a compile error like this:
Error running '__rvm_make -j1'
ossl_ssl.c:143:27: error: ‘SSLv3_client_method’ undeclared here (not in a function)
This has been discussed with the RVM team who have suggested installing this Ruby patch that allows older rubies to build:
$ curl https://github.com/ruby/ruby/commit/801e1fe46d83c856844ba18ae4751478c59af0d1.diff > openssl.patch
$ rvm install --patch ./openssl.patch 1.9.3-p194
I built ruby-1.9.3-p194, ruby-2.0.0-p247 and ruby-2.2.1 successfully with this patch.
Related
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've installed OpenSSL with rvm (rvm pkg install openssl) and then did rvm reinstall 1.9.3 --with-openssl-dir=$rvm_path/usr
When I try to run the thin webserver, I get the following error:
/home/ubuntu/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/x86_64-linux/openssl.so:
undefined symbol: SSLv2_method -
/home/ubuntu/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/x86_64-linux/openssl.so
(LoadError)
This is running on Ubuntu 12.04, and I've read that Ubuntu 12 builds OpenSSL without SSLv2 support. Yet, here it's referencing RVM's package -- does RVM do the same? Is there any known workaround for this problem?
As you say, Ubuntu builds openssl without SSLv2 support: Ubuntu and undefined symbol for SSLv2_method
For people reading this, your options are (in increasing difficulty):
(1) install rvm version 1.14.7, where the openssl pkg includes openssl version 0.9.8, and includes SSLv2 support by default.
rvm implode # Completely destroy your rvm installation
curl -L https://get.rvm.io | bash -s -- --version 1.14.7
Install the required packages, recompile your ruby, and it should work!
(2) (This gives you more security): Compile your own openssl from source, configuring it to include SSLv2 support, then recompile your ruby with the --with-openssl-dir pointing at wherever you installed openssl to.
(3) Fix thin so that it no longer requires the SSLv2_method symbol, then submit a pull request on GitHub
After getting Xcode rvm install 1.9.3 works totally fine. However, rvm install 1.8.7 throws the following error.
~ ☺ rvm install 1.8.7
Installing Ruby from source to: /Users/jordanscales/.rvm/rubies/ruby-1.8.7-p358, this may take a while depending on your cpu(s)...
ruby-1.8.7-p358 - #fetching
ruby-1.8.7-p358 - #extracting ruby-1.8.7-p358 to /Users/jordanscales/.rvm/src/ruby-1.8.7-p358
Error running 'tar xjf /Users/jordanscales/.rvm/archives/ruby-1.8.7-p358.tar.bz2 -C /Users/jordanscales/.rvm/tmp/rvm_src_30581 ', please read /Users/jordanscales/.rvm/log/ruby-1.8.7-p358/extract.log
There has been an error while trying to extract the source.
Halting the installation.
There has been an error fetching the ruby interpreter. Halting the installation.
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to Ruby 1.9.3-194 which will have all of the latest security patches.
~ ☺
The log reads
[2012-06-04 17:06:23] tar xjf /Users/jordanscales/.rvm/archives/ruby-1.8.7-p358.tar.bz2 -C /Users/jordanscales/.rvm/tmp/rvm_src_30581
ruby-1.8.7-p358/lib/test/unit/ui/gtk/testrunner.rb: (Empty error message)
tar: Error exit delayed from previous errors.
Any idea how to fix? I've tried rvm get head, installing gcc-4.2 and using that, using clang, etc. But nothing seems to work.
Make sure to satisfy all requirements specified by:
rvm requirements
Including Xcode 4.1 or osx-gcc-installer
Run (to fix broken download):
rvm cleanup archives
and try again:
rvm reinstall 1.8.7
Is there any reason why you are going with 1.8.7? it's about at end of life and 1.9.3 should be used instead if this is not an requirement.
Ruby keeps segfaulting when using the Koala gem to talk over HTTP:
/Users/pawel/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault
I've tried the following:
Run which -a ruby which showed multiple Rubies via MacPorts. So I deleted those and running the same command again returns only /usr/bin/ruby
I've removed the MacPorts version of PostgreSQL and installed it with Homebrew instead (With MacPorts, it installs its own version of OpenSSL)
Running openssl version returns OpenSSL 1.0.0g 18 Jan 2012
I removed Ruby 1.9.3 from RVM and tried Luciano's method below which didn't work.
I've also tried reinstalling 1.9.3 from RVM and specifying --with-openssl-dir=/opt/local since which openssl returns /opt/local/bin/openssl
I've reinstalled RVM (It's now version 1.10.2 in /Users/pawel/.rvm/bin/rvm)
I've upgraded to Ruby 1.9.3-p125 and have also tried on 1.9.2
I've followed the instructions here: http://www.christopherirish.com/2011/09/02/ruby-1-9-2-segmentation-fault-and-openssl/ (which are my above steps, actually). I've also read Christopher's previous post here.
In my project directory when I run the following then I get the expected 0.:
ruby -rubygems -e" require 'eventmachine'; require 'openssl' "; echo $?
I've tried to sudo port -f deactivate openssl but then when I try to start a Rails server I get Library not loaded: /opt/local/lib/libssl.1.0.0.dylib
I need some more ideas on what else I can try, or things I've missed.
I'm also getting this same Segmentation Fault error, but I'm trying to list files on AWS-S3.
Edit:
This way worked for me:
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:$HOME/.rvm/bin
rvm remove 1.9.3
rvm pkg install iconv
rvm pkg install openssl
rvm install ruby-1.9.3 --with-openssl-dir=~/.rvm/usr --with-iconv-dir=~/.rvm/usr
as #Simpleton said, I wrote a comment in the wrong place. Now I'm editing it with a response. ;-)
The problem seemed to be that Homebrew and MacPorts were conflicting, so I deleted MacPorts, removed all packages and the /opt/local/ directory. This caused some issue with the PG gem due to the PostgreSQL installation on Homebrew.
So I deleted the Postgres formula, then reinstalled it and ditto for the OpenSSL installation using Homebrew.
After that I imploded RVM and installed it and my Rubies again (not sure if this step was necessary) and finally it works.
I ran into this issue, too, but used a different solution. Here's the full stack trace of the error.
Here is the official bug report: http://bugs.ruby-lang.org/issues/6184 The responses below the stack trace were very helpful.
If you're using OS X's default openssl -> do like brew install
openssl and build with installed openssl, then try again.
If you're using openssl that installed by user -> build with OS X default ssl and try again.
This sounded similar to an issue for me recently when the readline library installed in MacPorts broke a ruby installation. Running the following script on the broken ruby installation showed it was loading the MacPorts openssl lib
require 'net/https'
puts `lsof -p #{$$} | grep ssl | awk '{print $9}'`
(the output)
/Users/john/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/x86_64-darwin11.2.0/openssl.bundle
/opt/local/lib/libssl.1.0.0.dylib
The solution was to temporarily move MacPorts out of /opt/local while installing ruby.
Quit all processes that are accessing MacPorts files. You can see which ones are running with sudo lsof | grep /opt/local.
sudo mv /opt/local /opt/localbak
Open a new terminal, then compile and install Ruby
sudo mv /opt/localbak /opt/local
After that, the ruby installation worked properly alongside MacPorts and did not load the libssl file from MacPorts.
I'm having issues requiring 'digest/sha1'.
~$ ./configure --prefix=$HOME/usr --program-suffix=19 --enable-shared
~$ make
~$ make install
~$ irb19
irb(main):001:0> require 'digest/sha1'
LoadError: dlopen(/Users/matan/usr/lib/ruby19/1.9.1/i386-darwin9.8.0/digest/sha1.bundle, 9): Symbol not found: _rb_Digest_SHA1_Finish
Referenced from: /Users/matan/usr/lib/ruby19/1.9.1/i386-darwin9.8.0/digest/sha1.bundle
Expected in: flat namespace
- /Users/matan/usr/lib/ruby19/1.9.1/i386-darwin9.8.0/digest/sha1.bundle
from (irb):1:in `require'
from (irb):1
from /Users/matan/usr/bin/irb19:12:in `<main>'
irb(main):002:0>
I know some standard modules require fine, while others don't. If i'd say require 'yaml' or even require 'digest' then that works fine. I am using OS X 10.5.8, with Ruby 1.9.1-p378. The system-wide install of Ruby 1.8.6 works fine.
Just last week I uninstalled Ruby and re-installed it. When I first installed Ruby I installed it in a similar manner, from source prefixed at my local $HOME/usr directory. I tried removing each and every file make install installs, then re-installing, but that didn't help.
Do you have an idea what the issue is and how to resolve it?
This is probably related to OpenSSL (Ruby uses OpenSSL for MD5/SHA1, at least if available). You could fix this by compiling a newer version of OpenSSL and linking against it on your own (./configure ... --with-openssl-dir=path/to/openssl).
Unfortunately you cannot install openssl via homebrew. However, apparently, if you are using macports, there is a port available: sudo port install openssl.
But what I would recommend is to simply use RVM:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
rvm package install openssl
rvm install 1.9.1 -C --with-openssl-dir=$HOME/.rvm/usr
You can then switch between 1.8 and 1.9:
rvm use system
ruby --version # => 1.8
rvm use 1.9.1
ruby --version # => 1.9.1
I did the compiling on my own for a long time, even wrote my own little script managing updating. But RVM ist just so much better at handling this. If you are going to try RVM, just swing by the #rvm channel at freenode, people are always willing to help there.
As an aside, 1.9.1 has a lot of rough edges and I would rather recommend switching to the 1.9.2 branch (or at least switch to 1.9.2p0 as soon as released).
Konstantin