开发者

LoadError in Ruby

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 fil开发者_如何转开发e 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜