When working with Ruby 1.9.3 on CentOS 5.8 through RVM, you might encounter this stubborn warning:
$ gem -v
/home/user/.rvm/rubies/ruby-1.9.3-p286/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.
1.8.24
The typical approach of running rvm pkg install libyaml
followed by rvm reinstall all --force
often doesn't resolve the issue because:
1. The installed libyaml version might be incompatible
2. The Ruby build process doesn't properly detect the library
3. System library paths aren't correctly configured
Here's a more effective approach that has worked consistently:
# First remove existing installations
rvm remove 1.9.3
# Install system-level libyaml development package
sudo yum install libyaml-devel -y
# Install Ruby with proper flags
rvm install 1.9.3 --with-libyaml-dir=/usr/local
After successful installation, verify psych is properly loaded:
$ ruby -rpsych -e "puts Psych.libyaml_version"
0.1.4 # Should output your libyaml version
$ ruby -ryaml -e "puts YAML::ENGINE.yamler"
psych # Should output 'psych' not 'syck'
If you encounter patch errors like the multilib error shown in the question:
1. Check the log file mentioned in the error
2. Try installing without patches:
rvm install 1.9.3 --verify-downloads 1 --movable --with-libyaml-dir=/usr/local --disable-patches
For complete control, install libyaml manually:
wget http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz
tar xzvf yaml-0.1.6.tar.gz
cd yaml-0.1.6
./configure --prefix=/usr/local
make
sudo make install
Then reinstall Ruby pointing to this location:
rvm reinstall 1.9.3 --with-libyaml-dir=/usr/local
After installing Ruby through RVM on CentOS 5.8, you might encounter this stubborn warning when running gem
commands:
/home/user/.rvm/rubies/ruby-1.9.3-p286/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.
Psych is Ruby's YAML parser that relies on libyaml. The warning appears because:
- libyaml isn't properly installed system-wide
- Ruby was compiled without psych support
- The installed libyaml version conflicts with Ruby's expectations
Step 1: Install System Dependencies
First ensure all development tools are available:
sudo yum groupinstall 'Development Tools'
sudo yum install openssl-devel readline-devel zlib-devel
Step 2: Proper libyaml Installation
Instead of using RVM's pkg system, install libyaml properly:
wget http://pyyaml.org/download/libyaml/yaml-0.1.7.tar.gz
tar xzvf yaml-0.1.7.tar.gz
cd yaml-0.1.7
./configure --prefix=/usr/local
make
sudo make install
Step 3: Reinstall Ruby with Correct Flags
Uninstall existing Ruby and reinstall with proper configuration:
rvm remove 1.9.3
rvm install 1.9.3 --with-libyaml-dir=/usr/local \
--verify-downloads 1 \
--movable
Step 4: Verify the Fix
Check if psych is now properly loaded:
ruby -rpsych -e "puts Psych::LIBYAML_VERSION"
ruby -ryaml -e "puts YAML::ENGINE.yamler"
Should output the libyaml version and "psych" respectively.
For newer RVM versions (1.25.0+), try:
rvm autolibs enable
rvm reinstall ruby-1.9.3-p286
If you encounter patch errors like in the question:
Error running 'patch -F 25 -p1 -N -f -i...'
Try installing without patches:
rvm install 1.9.3 --disable-patch-fetch
For production environments:
- Consider upgrading to Ruby 2.x+ which has better YAML support
- Use centralized libyaml installation to maintain consistency
- Document the exact installation procedure for reproducibility
Here's a sample verification script you can run:
#!/bin/bash
echo "Checking YAML engine..."
ruby -ryaml -e "puts 'YAML engine: ' + YAML::ENGINE.yamler"
echo "Checking Psych availability..."
ruby -rpsych -e "puts 'Psych loaded successfully!'" 2>/dev/null || \
echo "Psych not available"
echo "LibYAML version:"
ruby -rpsych -e "puts Psych::LIBYAML_VERSION" 2>/dev/null || \
echo "LibYAML version unavailable"