Collective Idea

Collective Idea Logo

Brian Ryckbost

Install Ruby 1.9.3 with libyaml on CentOS

By Brian Ryckbost on October 31, 2011 in how-to, install, libyaml, ruby, and yaml

Ruby 1.9.3-p0 makes psych—the replacement for 1.8.7’s YAML library, Syck—the default YAML parser. Psych is a wrapper around libyaml, so you’re going to need it installed and configured before installing Ruby.

If you install 1.9.3-p0 without libyaml, you’ll see warnings like this:

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

Installing libyaml

$ wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
$ tar xzvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4
$ ./configure --prefix=/usr/local
$ make
$ make install

Quick review of what’s going on: download and untar the source code, change to the directory and install the package. You may need to sudo the make install command. Your mileage may vary.

Installing Ruby 1.9.3-p0

$ wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
$ tar xzvf ruby-1.9.3-p0.tar.gz
$ cd ruby-1.9.3-p0
$ ./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
$ make
$ make install

After installing, you can verify that Ruby was installed with ruby -v. It’s also worth trying gem --version to make sure you don’t get any errors regarding psych.

I tried installing libyaml-devel and libyaml from Yum, but couldn’t get ruby installed and recognizing those packages. Out of frustration, I turned to installing libyaml by source and it Just Worked™.

By Brian Ryckbost on October 31, 2011 in how-to, install, libyaml, ruby, and yaml

23 Comments

  1. shapeshed

    shapeshed October 31, 2011 http://shapeshed.com

    If you don’t want to compile manually rbenv (with ruby-build) takes care of installing libyaml for you too

  2. Haris Amin

    Haris Amin October 31, 2011 http://blog.harisamin.com

    just a quick note, rvm will install libyaml for you too :)

  3. Brian Ryckbost

    Brian Ryckbost October 31, 2011 http://collectiveidea.com

    Haris Amin</strong> &amp; <strong>shapeshed: Great points! I should have pointed out this was for a server which isn’t using rvm or rbenv.

  4. Millisami

    Millisami November 01, 2011 http://nepalonrails.tumblr.com

    Yup, rvm 1.9.2 installs it https://gist.github.com/1329273#gistcomment-60100

  5. Vít Ondruch

    Vít Ondruch November 01, 2011

    You should be able to get installed libyaml from EPEL packages 1. Also, you should be able to build RPM packages for R1.9.3 from my spec file 2.

    1 https://admin.fedoraproject.org/pkgdb/acls/name/libyaml
    2 https://github.com/voxik/ruby.spec

  6. Tom

    Tom November 01, 2011 http://none

    I get error running ‘make’ and error running ‘make install’ when I use rvm install 1.9.3

    I cannot read the log since I do not understand it, but it is a log tied to the yaml-0.1.4 folder.

    I would like to use RVM since I want to make gemsets and being a newbie it gives me some security …lol

    Any suggestions on how I can let RVM know that ruby 1.9.3 is installed if I install from source using the above.

    Thanks,

    Tom.

  7. Brian Ryckbost

    Brian Ryckbost November 02, 2011 http://ryckbost.com

    @Tom: If you’re using RVM you won’t need to install libyaml from source. RVM will take care of that for you.

    To install Ruby 1.9.3-p0 via RVM run rvm install 1.9.3-p0

  8. Tom

    Tom November 02, 2011

    Hi Brian,

    Thanks for your reply to my earlier posting with respect to RVM install 1.93 and the subsequent errors as it tried to install yaml.

    That was the problem …. RVM tried to install Yaml 0.1.4 and in the process it gave me two warnings, one after the other and subsequently it did not install Ruby 1.9.3 even though it indicated that the installation was complete.

    The two warnings were, first “error running ‘make’” and the second was “error running ‘make install’”

    Maybe it is something about my setup …. I have just downloaded Ubuntu 11.10 for windows and I installed GIT and then RVM and they both worked just fine then I thought I would use RVM to install Ruby 1.9.3.

    I removed Ubuntu and now I am about to start all over … any other thoughts on this …. I know each installation is so different … but maybe you see a work around.

    Thanks again,

    Tom.

  9. Tom

    Tom November 02, 2011

    Hi Brian,

    Thanks for your reply to my earlier posting with respect to RVM install 1.93 and the subsequent errors as it tried to install yaml.

    That was the problem …. RVM tried to install Yaml 0.1.4 and in the process it gave me two warnings, one after the other and subsequently it did not install Ruby 1.9.3 even though it indicated that the installation was complete.

    The two warnings were, first “error running ‘make’” and the second was “error running ‘make install’”

    Maybe it is something about my setup …. I have just downloaded Ubuntu 11.10 for windows and I installed GIT and then RVM and they both worked just fine then I thought I would use RVM to install Ruby 1.9.3.

    I removed Ubuntu and now I am about to start all over … any other thoughts on this …. I know each installation is so different … but maybe you see a work around.

    Thanks again,

    Tom.

  10. Tom

    Tom November 02, 2011

    Hey Brian,
    I found a temporary work-around, that is for some folks it worked, unfortunately for me it did not.

    But if you are interested here is the link:
    https://github.com/wayneeseguin/rvm/issues/553

    Thanks,
    Tom.

  11. Tom

    Tom November 02, 2011

    Hey Brian,
    I found a temporary work-around, that is for some folks it worked, unfortunately for me it did not.

    But if you are interested here is the link:
    https://github.com/wayneeseguin/rvm/issues/553

    Thanks,
    Tom.

  12. djr

    djr November 08, 2011

    Great – thanks the libyaml build install worked for me – and fixed the same problem you described with the 1.9.3 install.

  13. invellsaima

    invellsaima November 09, 2011 http://twitter.com

    Hi! i’m repost you post: to my @urciibqo twitter

  14. Gerald Forster

    Gerald Forster November 14, 2011 http://derkalender.at

    For Debian Lenny, first add to /etc/sudoers:
    your_user ALL=NOPASSWD:/usr/bin/make

    Thany you! Gerald

  15. Gerald Forster

    Gerald Forster November 15, 2011 http://derkalender.at

    Correction.
    Sorry – it should bei Debian 6 – Squeeze.

    Best regards
    Gerald

  16. Christian Murphy

    Christian Murphy November 18, 2011

    Thanks for the useful tip.  I found that instead of
        —with-opt-dir=/usr/local/lib
    I need to run ./configure with
        —with-opt-dir=/usr/local
    (without the lib).  Otherwise, strace shows the loader trying to load the libyaml library from /usr/local/lib/lib.

  17. steve

    steve November 24, 2011

    thanks for your article this helpfull with me

    best regards

  18. Tyson Cung

    Tyson Cung January 24, 2012 http://thejupitech.com

    Why 1.9.3 is not yet recognize by rvm. Any ideas?

  19. Harsha

    Harsha January 27, 2012 http://sriharsha.net

    Thank you. After wasting time with apt yaml, I got here. Installing from source works great. Thanks.

  20. Rooby G

    Rooby G January 31, 2012 http://kiranatama.com

    Great tutorial, after a DAY trying to figure out how to install Ruby via other tutorials, this one was straight forward and easy to follow… you’re a life saver!!! TY!!! By the way could you also post a video for this?

  21. Philip Sampaio

    Philip Sampaio February 24, 2012 http://www.philipsampaio.com.br

    I have installed libyaml and libyaml-devel from yum(EPEL on CentOS 5) and I run:

    ./configure —with-opt-dir=/usr/include/

    Them, make and make install.
    It works!

    Thanks!

  22. David

    David March 14, 2012

    I was hitting my head against the wall until I tried Ruby 1.9.3-p0 not the latest Ruby 1.9.3-p125.

    Thanks!

  23. Seth A. Roby

    Seth A. Roby May 07, 2012

    I got this working by changing the ruby configure line to:

        ./configure —prefix=/usr/local —enable-shared —disable-install-doc —with-opt-dir=/usr/local

    This picks up the library and the include file itself, which is apparently important, now.

Post a Comment

Contact Us

Find us on Google Maps
Collective Idea
25 West 8th Street, Suite 200
Holland, Michigan 49423 USA 42.790299-86.108415

Follow us on the Interwebs

We are currently available for medium and long term projects. Please get in touch if we can be of service.