17

Whenever I run something with Ruby on my server, I get the following error:

/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.

I installed Ruby using RVM onto my VPS.

I’ve tried installing the package libyaml as per instructed in other issues on Stack Overflow, to no avail.

I’m not sure what type of system my VPS is running, but it doesn’t have the apt-get command. It does have yum

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338

8 Answers8

21

I have to disagree with @JunaidKirkire in that I think you are running CentOS or Redhat 5 which uses a a very old version of Ruby by default and I think using RVM is a much better way to go. I believe you will just need to compile libyaml from source with the following:

rvm pkg install libyaml

This will tell you the directory that it is compiling into, in my case, it is /Users/ehowe/.rvm/usr

You then need to recompile Ruby with the following option:

rvm reinstall 1.9.3 --with-libyaml-dir=$directory_that_rvm_installed_libyaml_to

So in my case, I would do:

rvm install 1.9.3 --with-libyaml-dir=/Users/ehowe/.rvm/usr

If you are running rvm as root, this will get installed into /usr/local/rvm/usr. If you are running it as a user, as is recommended, it would be /home/$user/.rvm/usr

Eugene
  • 4,829
  • 1
  • 24
  • 49
  • Does this look correct: `rvm reinstall 1.9.3 --with-libyaml-dir=/usr/local/rvm/src/yaml-0.1.4`. Or would it just be? `rvm reinstall 1.9.3 --with-libyaml-dir=/usr/local/rvm`? –  Oct 15 '12 at 21:52
  • After running `rvm pkg install libyaml` and then `rvm reinstall 1.9.3 --with-libyaml-dir=/usr/local/rvm/src/yaml-0.1.4`, I am still getting the `psych` warning. –  Oct 15 '12 at 21:59
  • 1
    You should just use `/usr/local/rvm/usr` as the path.I tested this and it worked. – Eugene Oct 16 '12 at 01:35
  • Are you absolutely sure you used the correct path? I tested this on a clean CentOS 5.8 install and it worked for me. Can you try it again and send me a gist with the complete output from start to finish? – Eugene Oct 18 '12 at 12:33
  • http://hastebin.com/mewexusidu.vbs — example of the error immediately after reinstalling at the bottom. –  Oct 18 '12 at 15:12
  • Thank you! Solved my problem: http://serverfault.com/questions/442150/how-to-fix-ruby-installation-is-missing-psych-for-yaml-output-on-centos – ohho Oct 25 '12 at 08:08
  • Sorted my problem on CentOS 6.3 using `--with-libyaml-dir=/home/$user/.rvm/usr`. Thanks! – sgb Oct 26 '12 at 13:18
  • I had same issue on Ubuntu and this solved it for me. Many other suggestions did not work. Thanks! – Chris Markle Nov 14 '12 at 01:55
12

I had this problem and installing libyaml didn't help. It turned out that libyaml-devel was needed by psych. I was on centos6 so I did this:

curl -O http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/atomic-release-1.0-14.el6.art.noarch.rpm

sudo  rpm -Uvh atomic-release-1.0-14.el6.art.noarch.rpm

sudo yum install libyaml-devel

rvm reinstall 1.9.3-p194
Julian Mann
  • 6,256
  • 5
  • 31
  • 43
  • When I run sudo `rpm -Uvh atomic-release-1.0-14.el6.art.noarch.rpm`, I get: `warning: atomic-release-1.0-14.el6.art.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 5ebd2744 error: Failed dependencies: rpmlib(FileDigests) <= 4.6.0-1 is needed by atomic-release-1.0-14.el6.art.noarch rpmlib(PayloadIsXz) <= 5.2-1 is needed by atomic-release-1.0-14.el6.art.noarch` –  Oct 16 '12 at 16:14
  • What OS? Could you run in a shell: uname -a and post the output here please – Julian Mann Oct 18 '12 at 11:16
  • If it is Fedora you are running, search rpm.pbone.net for: libyaml-devel fedora rpm - for your version. For example, Fedora 16 x86_64 will take you here http://rpm.pbone.net/index.php3/stat/4/idpl/17341900/dir/fedora_16/com/libyaml-devel-0.1.4-1.fc16.x86_64.rpm.html. – Julian Mann Oct 18 '12 at 11:22
  • Linux server9987 2.6.32-042stab049.6 #1 SMP Mon Feb 6 19:17:43 MSK 2012 i686 i686 i386 GNU/Linux –  Oct 18 '12 at 15:02
  • ok - so its openvz server. Maybe I should not have pointed to the x86_64 repo. sorry. Seems you can get libyaml-devel for i386 in this repo: http://www6.atomicorp.com/channels/atomic/redhat/6/i386/RPMS/atomic-release-1.0-14.el6.art.noarch.rpm . – Julian Mann Oct 18 '12 at 15:18
  • Running the above commands with that repo instead gives me exactly the same error as before (see above comment). Sorry if I seem like a n00b. Appreciate your guidance. –  Oct 18 '12 at 19:36
  • You have errors of unresolved dependencies that don't appear on my system - try to install those dependencies it asks for: FileDigests and PayloadIsXz. I have no idea what they are. If succeed, then install libyaml-devel, and then reinstall ruby. I just searched for libyaml-devel openvz and found some a link that suggests: wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm -- then -- rpm -ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm -- then -- yum install libyaml-devel ... sorry I can't try any of this out. – Julian Mann Oct 22 '12 at 17:48
  • Ran the commands you mentioned at the end of your comment and then reinstalled Ruby: `rvm reinstall 1.9.3`. Sorted! Thank you very, very much. –  Oct 23 '12 at 16:20
  • Complete installation process (CentOS 6.3, Ruby) https://gist.github.com/denispeplin/5011950 – denis.peplin Feb 22 '13 at 09:24
8

On a RHEL based distro such as CentOS 6.x you need to add another yum repository such as EPEL which contain the libyaml-devel package.

Keys for EPEL or download
RPM for EPEL

More info:

Would also suggest the use of yum-plugin-priorities

Add EPEL Yum Repository

rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
rpm -Kih http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Install libyaml-devel via yum

yum -y install libyaml-devel

Packages

Dependencies Resolved

====================================================================================
 Package                       Arch         Version           Repository       Size
====================================================================================
Installing:
 libyaml-devel                 x86_64       0.1.3-1.el6       epel             84 k
Installing for dependencies:
 libyaml                       x86_64       0.1.3-1.el6       epel             52 k

Transaction Summary
====================================================================================
Install       2 Package(s)
Community
  • 1
  • 1
codemonkee
  • 2,881
  • 1
  • 25
  • 32
3

The problem could be solved by installing libyaml. Below are the corresponding packages for the most popular distributions:

  • Fedora libyaml
  • Ubuntu and other Debian based libyaml-dev
  • Some other like CentOS libyaml-devel

and also you should install the following to avoid similar problems in future:

ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
Itay Grudev
  • 7,055
  • 4
  • 54
  • 86
Yasin
  • 287
  • 5
  • 15
  • “No package libyaml available.” –  Oct 19 '12 at 19:48
  • yes it should solve the problem. and if it does, please tick it as an answer :) – Yasin Oct 19 '12 at 22:58
  • libyaml installed with `rvm pkg`, then I re-installed Ruby 1.9.3 with `rvm`. Still the same problem. –  Oct 20 '12 at 17:55
  • Tried installing `libyaml-devel` as per http://stackoverflow.com/a/12919013/1082754. Couldn’t get the install to work, however – and it’s not in Yum. –  Oct 21 '12 at 10:33
  • try apt-get install pkg_name if its ubuntu, if u cant find, try apt-get search pkg_name – Yasin Oct 21 '12 at 18:16
  • I don’t have the `apt-get` command. Running Fedora, Centos 5.8. –  Oct 21 '12 at 18:35
  • If you are using fedora u must use sudo yum install pkg_name – Yasin Oct 21 '12 at 22:12
  • It’s not solved, sorry. See comments in other answers for trouble I’m having with yum. –  Oct 22 '12 at 21:02
1

In case people still hit this, I fixed it using the new autolibs feature in RVM, which automatically installs dependencies using your homebrew libraries (check out rvm help autolibs for info.)

rvm reinstall 1.9.3 --autolibs=2

Arrel
  • 13,558
  • 7
  • 26
  • 24
0

You seem to be working on Fedora. Check the official Ruby website for instructions on installing on Fedora.

Try this link too http://sraji.wordpress.com/2011/01/25/how-to-install-ruby-on-fedora-14/

JunaidKirkire
  • 878
  • 1
  • 7
  • 17
  • How do I install rubygems with that? –  Oct 14 '12 at 12:40
  • @OliverJosephAsh: Rubygems come installed by default when you install Ruby. – JunaidKirkire Oct 14 '12 at 12:43
  • `ruby -v` // ruby 1.8.5 (2006-08-25) [i386-linux]. `gem` // bash: gem: command not found –  Oct 14 '12 at 12:47
  • @OliverJosephAsh try this link http://www.technetra.com/2009/04/22/howto-setting-up-ruby-on-rails-for-fedora-10-and-11/ Follow the above instructions and you will be fine. Good luck. – JunaidKirkire Oct 14 '12 at 12:51
  • Is there anyway I can find out what the latest version of rubygems is that will work with ruby 1.8.5? Or can I get yum to install 1.9.3 in any way? –  Oct 14 '12 at 12:59
  • What version of Fedora/Redhat/CentOS is your VPS running? You can find out with `cat /etc/redhat-release` – Eugene Oct 14 '12 at 13:42
  • CentOS release 5.8 (Final) (Thank you) –  Oct 14 '12 at 13:59
0

I had this same libyaml issue with CentOS 6.2

Doing...

rvm pkg install libyaml
rvm reinstall 1.9.3 --with-libyaml-dir=/usr/local/rvm/usr

Fixed it for me.

(thanks to @Eugene)

Community
  • 1
  • 1
max kaplan
  • 541
  • 4
  • 13
0

Make sure your Redhat machine has a valid subscription:

# subscription-manager list 

+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:   Red Hat Enterprise Linux Server
Product ID:     69
Version:        7.1
Arch:           x86_64
Status:         Subscribed
Status Details: 
Starts:         06/13/2014
Ends:           06/12/2015

Status must say "Subscribed". If not, then suffer through getting a login and maybe purchasing a subscription at https://access.redhat.com/management/consumers.

When that's done, run

# subscription-manager repos --enable rhel-7-server-optional-rpms

then libyaml-devel will install OK.