This is a note to myself because this has happened to me more than once. I’m posting it publicly in case it helps others, too.
I ran across this with the very nice Sucker gem, which lets you easily access the Amazon Product Advertising API. Amazon requires SHA-256 in its API calls, which is where my trouble began.
If your Ruby app got this error message in openssl/digest.rb:55:
Unsupported digest algorithm (sha256).
it’s because when you installed (compiled) Ruby, you linked in an older version of the openssl library.
I Like Stuff that Finally Worked
Here’s how I fixed it:
brew install openssl rvm remove 1.8.7 rvm install 1.8.7 --with-openssl-dir=/usr/local/Cellar/openssl/0.9.8o/
To test it, run this in the Terminal:
ruby -ropenssl -e 'p OpenSSL::Digest::Digest.new("sha256")'
If you don’t get an error message, it worked.
Things That Didn’t Work
Installing and building openssl from source (openssl.org) did not work.
Installing the openssl rvm package and removing+reinstalling ruby did not work.
What finally worked was the steps above. Woo hoo!
By the way, I did not have to upgrade to Snow Leopard.
What about Ruby 1.9.2?
I still haven’t gotten it working in Ruby 1.9.2. I run this:
rvm install 1.9.2 --with-openssl-dir=/usr/local/Cellar/openssl/0.9.8o/
and I get this output:
ruby-1.9.2-p136 - #fetching ruby-1.9.2-p136 - #extracted to /Users/Brian/.rvm/src/ruby-1.9.2-p136 (already extracted) ruby-1.9.2-p136 - #configuring ruby-1.9.2-p136 - #compiling Error running 'make ', please read /Users/Brian/.rvm/log/ruby-1.9.2-p136/make.log There has been an error while running make. Halting the installation.
So I go look in make.log and I see this at the end:
Generating RDoc documentation ./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb ./tool/runruby.rb --extout=.ext -- "./bin/rdoc" --no-force-update --all --ri --op ".ext/rdoc" "." /Users/Brian/.rvm/gems/ruby-1.8.7-p330/gems/rdoc-3.4/lib/rdoc/rdoc.rb:79: warning: already initialized constant GENERATORS uh-oh! RDoc had a problem: undefined method `coverage_report' for #<RDoc::Options:0x7841a0>
Does anyone know how to fix it?