Tuesday, November 13, 2012

Solution to “ruby installation is missing psych” Error

To save yourself from this headache, install yaml first before installing Ruby. 


I'm still trying to install Ruby on Rails on Ubuntu 12.04 and I got this warning after I installed RubyGems:

It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.

I googled this error and it seems several people had this problem too. A bug??? Yep. (If you're installing Ruby from rvm, refer to thisthis and/or this) Unfortunately, their solutions won't work for me because I'm installing Ruby from source not from rvm. So I decided to follow the instruction please install libyaml and reinstall your ruby and prayed it'd work.

I installed libyaml:

tar -xvzf yaml-0.1.4.tar.gz
cd yaml-0.1.4/
sudo ./configure && sudo make && sudo make install

Then "reinstalled" Ruby from Source:


wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar -xvzf ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327/
sudo ./configure && sudo make && sudo make install

When I typed gem -v, I still got the same error. :( I googled for the error and found this SO answer as my saving grace.

I recompiled yaml module:

cd ruby-1.9.3-p327/ext/psych
sudo ruby extconf.rb
sudo make && sudo make install

Judgement time. *drum roll*  To test, I typed gem -v

Aaaaaaaaaannnnnndddddd no error. I got my gem version: 1.8.24. Yipee. :)

Sweetness... 


A little explanation for myself (and to others who are curious):
## recompiles yaml or any other module
cd ruby-1.9.3-p327/ext/<module folder>
sudo ruby extconf.rb

## reinstall Ruby
sudo make && sudo make install

No comments:

Post a Comment