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
Related
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.
I just installed ruby 2 on MacMountainLion, how to install gems? Actually I have both installed but there is something wrong. Maybe a fresh installation would solve.
macbook:~m$ gem install rails
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
macbook:~ m$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]
macbook:~ m$ gem -v
2.0.3
macbook:~ m$
I had the same problem, but fixed it as follows:
Apparently OS X Mountain Lion has an older version of OpenSSL than Ruby 2 will tolerate. Download and install the latest OpenSSL using ./Configure darwin64-x86_64-cc --prefix=/usr/local --openssldir=/usr/local/openssl; make; sudo make install. Then build Ruby using ./configure --with-openssl-dir=/usr/local/openssl; make; sudo make install. Ruby's configure complains that --with-openssl-dir is an unknown option, but the build apparently uses it anyway because anything that depends on SSL, including gem installs, now works.
Installing gem like rails needs lot of dependent libraries which you have to download and install it manually
Alternatively you can try using Homebrew to install all the dependent libraries. If you are new to ROR development I strongly recommend you to use rvm to manage different versions of ruby
Once you have installed all the necessary dependent libraries using Homebrew then Its fairly straight forward to install a gem, execute the following after replacing "gemname" with the gem you are interested in
gem install <<gemname>>
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 new to ubuntu, and might have had a couple of
false starts updating ruby / rails. I'm trying
to start clean by removing all versions of every
thing ruby from my system
I think I've installed everything through either
Synaptic, or aptitude purge, but I can still do the
following:
jwally#jwally-laptop:~$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
jwally#jwally-laptop:~$ gem -v
1.3.7
jwally#jwally-laptop:~$ irb
irb(main):001:0> RUBY_VERSION
=> "1.9.2"
but when I type "dpkg -l | grep ruby,
I only get the following:
rc ruby1.8-elisp 1.8.7.249-2 ruby-mode for Emacsen
thanks in advance
You may have installed an instance of Ruby without using Ubuntu's package system. Try:
which ruby
If this yields something other than /usr/bin/ruby (such as /usr/local/bin/ruby), then this is the case. Ubuntu can't uninstall locally installed stuff. You need to do that manually.
To see which package ruby is owned by run:
dpkg -S `which ruby`
If it can't find the package, then Ruby was installed outside of the Ubuntu package manager. You'll have to remove it manually.
I'll once again recommend this blog post for instructions on the best way to install Ruby on Ubuntu: Ubuntu, Ruby, RVM, Rails, and You.
I have been trying to get Rails 3 installed in Fedora, it requires Ruby to be 1.8.7 or 1.9.2. Fedora official yum repos have Ruby 1.8.6 which is of no use. So I decided to compile it myself from the source, downloaded the source, compiled it and installed it successfully.
But this weird thing happens after the install, sudo gem or sudo ruby are not working, it just returns saying command not found.
which ruby
/usr/local/bin/ruby
ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
sudo ruby
sudo: ruby: command not found
sudo echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
Am I missing something, why doesnt it find ruby when its in the PATH?
check your PATH variable (set in your .bash_profile or .bashrc file, add /usr/local/bin to the front of the PATH:
PATH=/usr/local/bin:$PATH
I'd recommend that you check out RVM -- so far the best way to install and switch between different Ruby versions and to maintain Gems independently for each version!
https://rvm.io
Using RVM is much easier than compiling by hand, and it keeps all your Gems organized by Ruby version!
There's also a RailsCast on it: http://railscasts.com/episodes/200-rails-3-beta-and-rvm