Unable to resolve Ruby error (missing psych) - ruby

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…

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

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

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:
CentOS - Additional Resources
Fedora Project: EPEL Howto
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)

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

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

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/

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)

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.

Related

Couldn't require openssl in ruby

I have openssl installed in my virtual machine ubuntu12.04lts.
When I run the gem command it gives error.
Error: while executing gem (Gem::Exception)
Unable to require openssl. install openSSL and rebuilt ruby (preferred) or use non HTTPs sources
And I also test require openssl in irb mode.
it gives error.
Loaderror: cannot load such file --openssl
from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55 `require'
I have openssl
$openssl version
OpenSSL 1.0.1 14 mar 2012
How to fix the error?
Note: Calls to rubygems.org are deprecated - proceed with caution!
I had the same issue on Mac OSX after also building ruby2.1.0p0 from the source. I already had openssl installed. It appears that the reference in gems needed refreshing. I ran:
gem source -r https://rubygems.org/ to remove
followed by
gem source -a https://rubygems.org/ to read
After this, I was able to run gems install bundler successfully.
If you run into further errors, you can try ./configure --with-openssl-dir=/usr/local/ssl in your ruby downloaded dir/.
I got this error while using debian where openssl was in /usr/bin.
Following the suggestion of jspacek I reconfigured ruby using:
./configure --with-openssl-dir=/usr/bin
After make and sudo make install I was able to install rails.
make sure you have libssl-dev installed:
dpkg -s libssl-dev
if not, install it:
sudo apt-get -y install libssl-dev
In case someone else has this problem, try reinstalling your Ruby version with openssl included
brew install openssl
rvm reinstall 2.4.0 --with-openssl-dir=`brew --prefix openssl`
You might already have openssl - so you can ignore the first step.
This helped me.
I'm leaving this answer for reference to future Googlers:
Type all these commands in your Terminal (OSX) just to be extra sure you've done everything (this is what eventually worked for me)
rvm get stable
brew update
brew doctor
brew install openssl
rvm install ruby-2.1 (or whatever version)
rvm use (ruby version here) i.e. rvm use ruby-2.1
rvm gemset create NAME i.e. rvm gemset create rails41
gem install rails -v 4.1
Finally...
As many commenters have pointed out - you need OpenSSL installed before you compile ruby before you install rails (or other gems)
You probably built Ruby from source before installing OpenSSL. Make sure you install it and then try reconfiguring and rebuilding Ruby.
Recently I was struggling with ruby installations due to the recent auto-update in openssl version from 1.0 to 1.1 and wanted to revert it back to older version. No other solution except the one given below worked for me:
brew install rbenv/tap/openssl#1.0
rvm reinstall 1.9.3-p551 --with-openssl-dir='/usr/local/opt/openssl#1.0'
gem update --system
Now my ruby runs with openssl 1.0 whereas all other libraries are running on the default openssl version 1.1.
Rebuilding Ruby after running sudo apt-get install libssl-dev libreadline-dev libgdbm-dev can solve this issue.
I found this solution here.
I was getting this error installing Ruby with RVM. Nothing worked. I switched to rbenv. Problem solved!
for me it was a case of missing dependencies.
i thought i had all the dependencies required to install ruby, but i too was getting an openSSL and readline error.
i attempted to install ruby with RVM without root privileges which failed but gave me a list of missing dependencies. i then installed the dependencies with a package manager. i then re-attempted to install ruby from source from the beginning, and everything worked OK
the dependencies that were missing, for me, were:
patch libyaml-devel autoconf gcc-c++
readline-devel libffi-devel openssl-devel
automake libtool bison sqlite-devel
but they may be different for you.
update: i don't originally remember where exactly i found this list, but a quick search found similar lists on the following pages, which might also help you:
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-on-centos-6-with-rvm
http://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/install-ruby-on-rails-on-centos-ubuntu-fedora-from-source.html
These steps worked for me:
Fixed ruby install:
brew upgrade openssl;
openssldir=which openssl
rvm reinstall ruby-2.4.2 --with-openssl-dir=$openssldir
Removed and re-added sources for gems
gem sources -r https://rubygems.org/
gem sources --add https://rubygems.org/
i had similar issue and tried to solve it by following guides. The "rebuild ruby" is an important step!
after openssl_devel is installed
cd folder_of_ruby_source_code/ext/openssl
ruby ./extconf.rb
make
make install
cd folder_of_ruby_source_code
./configure
make clean <= clean is important here
make
make install
Do you use RVM?
If not, try using it and see if it fixes your problem.

Error installing any ruby version with RVM on OSX

Guys I'm about to kill myself with this one!
I had some problems with RVM installing multiple versions of Ruby, and following a thread on Stackoverflow I decided to remove it completely. After reinstalling RVM, I am unable to install any Ruby version at all.
Mac OS X
RVM 1.20.10 stable
Homebrew 0.9.4
Here are some logs:
rvm install 2.0.0-p0
or:
rvm install 2.0.0-p195 --autolibs=enabled
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-2.0.0-p0.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing requirements for osx, might require sudo password.
Already up-to-date.
Installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libxml2, libxslt, libksba, openssl…
Error running 'requirements_osx_brew_libs_install autoconf automake libtool pkg-config libyaml readline libxml2 libxslt libksba openssl',
please read /Users/admin/.rvm/log/ruby-2.0.0-p0/1368903329_package_install_autoconf_automake_libtool_pkg-config_libyaml_readline_libxml2_libxslt_libksba_openssl.log
Logfile reads:
[2013-05-18 22:55:29] requirements_osx_brew_libs_install
Error: No such keg: /usr/local/Cellar/autoconf
There were package installation errors, make sure to read the log.
Check Homebrew requirements github.com/mxcl/homebrew/wiki/Installation
brew doctor
Your system is ready to brew.
brew cleanup
Removing: /Library/Caches/Homebrew/automake-1.13.1.tar.gz…
Error: Permission denied — /Library/Caches/Homebrew/automake-1.13.1.tar.gz
brew reinstall autoconf
Error: No such keg: /usr/local/Cellar/autoconf
Help!
I ran into the same issue, you need to manually install all the required packages using Brew. For me I had to run the following installs:
brew install autoconf
brew install automake
brew install libtool
brew install apple-gcc42
brew install libyaml
brew install libxslt
brew install libksba
brew install openssl
You just need to keep running "rvm requirements" and reading the log and installing the packages needed until there are no more errors.
After installing RVM, You'll want to run
rvm requirements
to see if anything else is required to install ruby and rails first.
here is the similar question asked rvm install ruby
This solved problem for me
sudo chown -R `whoami` /Library/Caches/Homebrew/
I had the same problem
brew install pkg-config
worked for me
I aswell ran into the permission problem. My /usr/local/opt where the packages are linked had permissions root:wheel. I changed permissions by doing
sudo chown -R <localuser>:staff /usr/local/opt
where of course "localuser" is your local user you used to install brew.
Then aswell I had to run
brew reinstall autoconf
and so on instead of just "install", since brew always kept on saying the lib already was installed (yet not linked). "reinstall" simply forces a new install of the package. that did the trick for me.
Hope this helps someone with similar problems.
User which is running brew should have write access to This entire directory path
/Library/Caches/Homebrew/Formula
No need to change ownership just write permission. then running rvm works
I was encountering similar issues, particular around the install of openssl098. I came across this Homebrew issue, tried rvm get head as suggested, and now rvm works perfectly.
I'd try to install Xcode Command Line Tools before.
Try
rvm reinstall ruby-2.3.1 --with-openssl-dir=`brew --prefix openssl`
rvm openssl on Mojave

what is osx_brew and can i install it in my ubuntu machin?

I have tried so many tries to correct the issues with ruby version. In between somewhere i have installed osx_brew in my machine. Actually i don't know why i have install this. After a short googling i can found that the osx_brew only needed for mac os. I don't know that is correct or not. Any way when i try to install rvm requirements i got the error like
Installing requirements for osx_brew, might require sudo password.
Already up-to-date.
Installing required packages: autoconf, automake, libtool, pkg-config, apple-gcc42, libyaml, readline, libxml2, libxslt, libksba, openssl, sqlite...
Error running 'requirements_brew_libs_install autoconf automake libtool pkg-config apple-gcc42 libyaml readline libxml2 libxslt libksba openssl sqlite',
please read /home/anoop/.rvm/log/package_install_autoconf_automake_libtool_pkg-config_apple-gcc42_libyaml_readline_libxml2_libxslt_libksba_openssl_sqlite.log
There were package installation errors, make sure to read the log.
Check Homebrew requirements https://github.com/mxcl/homebrew/wiki/Installation
i don't know whether this problem arises due to homebrew or not.
Also when i try the command rvm autolibs status
it shows me like
---
value: osx_brew
number: 4
runner: osx_brew
description: Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X).
It says like only for osx_homebrew. Do i need to install when i working in rvm ruby if yes can you tell me the purpose of that. If i don't need this how can i remove this in my ubuntu system?

Ruby and "You must recompile Ruby with OpenSSL support or change the sources in your Gemfile"

Using rvm I upgraded my ruby to 1.9.3-p392, also added 2.0.0, anytime I try to use this version when I run my bundle command I get this error.
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using RVM are
available at rvm.io/packages/openssl.
I have followed several different instructions on how to fix this. I have tried removing the version and installing it with the rvm options
--with-openssl-dir=$HOME/.rvm/usr
I have installed OpenSSL with rvm, and macports. Both have not helped the problem. I even changed the file location of the ssl cert using this:
export SSL_CERT_FILE=/Users/DarkLord/.rvm/usr/ssl/cert.pem
No matter what I do I continue to get the error.
Can someone please help me fix this?
This works for me:
rvm get stable
brew install libyaml
rvm pkg install openssl
rvm install ruby-2.0.0 --with-openssl-dir=$HOME/.rvm/usr
rvm use ruby-2.0.0
All credits go to https://coderwall.com/p/tptocq
This helps me install 1.9.3-head on Mac:
rvm get latest
brew install openssl
rvm reinstall 1.9.3-head --with-openssl-dir=`brew --prefix openssl`
In my case after:
1. brew install openssl
2. rvm install ruby-2.6.0
bundle install failed with this error. The problem was that openssl was globally set so I had to install the new ruby version by setting the openssl directory explicitly.
So what I had to do was:
1. rvm reinstall ruby-2.6.0 --with-openssl-dir=/usr/local/opt/openssl
2. rvm reload
Assuming that usr/local/opt/openssl is where it is installed.
After that bundle install ran successfully.
Warning when I tried this command with this path /usr/local like some answers suggested, it didn't work.
To get this working again I had to install homebrew and move my mac ports out of the way. Then do the following after removing 1.9.3-p392 and 2.0.0-p0:
rvm get head --autolibs=3
rvm install 1.9.3 --with-opt-dir=/usr/bin
rvm install 2.0.0
There was something not working with my mac ports and openssl and make and configure. This was the only way I was able to get rvm to install ruby again with out getting openssl issues or make/configure issues.
The new way to do it, according to a comment by #Purplejacket above, is the following:
rvm autolibs homebrew
rvm install 2.1.1
rvm use 2.1.1
It's much easier.
In my case:
Problem: After installing ruby-2.3.1, I ran the command bundle install and then the error occurred.
Solution:
I first installed OpenSSL on my machine. $ brew install openssl
And then, reinstalled the ruby version I require (2.3.1) with the openssl.
$ rvm reinstall 2.3.1 --with-openssl-dir=/usr/local/opt/openssl
And this solved my problem!
According to the following question:
How to tell which openssl lib is actually being used by an RVM-installed ruby
It seems that the options --with-openssl-dir=... is no longer valid as of Ruby 1.9.3. I tried
rvm install 1.9.3 --with-opt-dir=/usr/local --with-openssl
and it worked.
macOS Catalina
brew install rbenv/tap/openssl#1.0
rvm reinstall 2.3.8 --with-openssl-dir=/usr/local/opt/openssl#1.0
The following steps worked for me.
First ensure openssl is installed by running brew install openssl, then reinstall the ruby version using rvm, but this time around, you have to pass the with-opt-dir flag pointing to the location where openssl was installed on your machine (use command which openssl to find this location).
rvm install 1.9.3-p392 --with-openssl-dir=/usr/local/opt/openssl
On macOS 10.14, Ruby 2.5.3, and OpenSSL 1.0.2n this worked for me:
./configure --with-openssl --with-openssl-dir=/usr/local/ssl
but I was only trying what the error messages were telling me:
*** Following extensions are not compiled:
openssl:
Could not be configured. It will not be installed.
/Users/brian/Desktop/Ruby/ruby-2.5.3/ext/openssl/extconf.rb:97: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
Check ext/openssl/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
make[1]: *** [note] Error 1
I encountered this issue when working on a Ruby 2.2.3 application.
I had previously uninstalled the MySQL database server on my machine, since I did not need it. However, I still needed the mysql2 gem since my application was connecting to another application's MySQL database to pull data.
However, when I try to run the bundle command I get the error:
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using RVM are
available at rvm.io/packages/openssl.
Here's how I solved it:
The issue was caused by removing the libssl-dev library when I was uninstalling the MySQL database server on my machine and its libraries.
First I ran the command below to reinstall ruby since I installed it using rvm:
rvm reinstall ruby-2.2.3
This raised an error:
Making gemset ruby-2.2.3 pristine............................................./-
.'command gem pristine --extensions mysql2 --version 0.5.3' failed, you need to fix these gems manually.
.
Error running '__rvm_with ruby-2.2.3 gemset_pristine',
please read /home/promisepreston/.rvm/log/1630094455_ruby-2.2.3/gemset.pristine-ruby-2.2.3.log
Next, I tried to install the mysql2 gem:
gem install mysql2
Then I ran into this error:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
mysql client is missing. You may need to 'sudo apt-get install libmariadb-dev', 'sudo apt-get install libmysqlclient-dev' or 'sudo yum install mysql-devel', and try again.
Finally, I installed the mysql client library using the command:
sudo apt-get install libmysqlclient-dev
Note: This also installs the libssl-dev library alongside.
And everything worked fine.
That's all.
That's what helped me:
rvm reinstall 2.5
brew tap raggi/ale
brew install openssl-osx-ca
brew services start openssl-osx-ca
Found this solution here: https://github.com/raggi/openssl-osx-ca#readme
I specified a more recent Ruby version in my Gemfile, then ran bundle install. All good now.
Specific case for ruby version 3.0.3
By default for brew and system and autolibs OpenSSL version is 3. Ruby 3.0.3 does not work with OpenSSL version 3 and ruby build silently ignores OpenSSL.
To build ruby properly use build options with OpenSSL 1 like this:
PKG_CONFIG_PATH=/usr/local/opt/openssl#1.1/lib/pkgconfig rvm reinstall 3.0.3 --with-openssl --with-openssl-lib=/usr/local/opt/openssl#1.1/lib --with-openssl-include=/usr/local/opt/openssl#1.1/include
Where path variables may be another - check your system.
Thanks to article Ruby 3.0.3 with OpenSSL using MacPorts and RVM
I got this to work on Ubuntu 22.04 by doing:
rvm pkg install openssl
...and adding --with-openssl-dir=$HOME/.rvm/usr to the rvm install command.
This doesn't seem particularly OS-specific and might work on Mac OS as well.
Fix which worked for me
rvm install 3.0.3 --with-openssl-dir=/opt/homebrew/etc/openssl#1.1
PS. Find the correct openssl location in your machine and install ruby pointing to that path like above, mentioning the brew installed openssl#3 path doesnot work.
I don't use rvm, and I don't want to. I had to install asdf in order to resolve what I used to be able to do with just homebrew & ruby.
Following this guide is the only thing that worked for me after following dozens of suggestions. I had to install asdf and update my .zshrc to include the following at the end of the doc:
eval "$(rbenv init - zsh)"
I'm on an Intel Mac running Monterey 12.2.1.

Where can I get a Ruby 1.8.6 for Centos OS

Can anyone tell me where I can find a Ruby 1.8.6 so I can istall it in my Centos 5 machine?
Thank you.
Download tarball with your version of Ruby from here
tar -xjvf ruby-1.8.6-pxxx.tar.bz2
cd ruby-1.8.6
./configure
make
make install
I had to do exactly what you are asking for, I just used version 1.8.7
You probably want this:
"To use with yum, create /etc/yum.repos.d/ruby.repo and add the following:"
[ruby]
name=ruby
baseurl=http://repo.premiumhelp.eu/ruby/
gpgcheck=0
enabled=0
————————————————————————–
"Sample usage:"
yum --enablerepo=ruby list *RUBY*
Googleage: http://krnjevic.com/wp/?p=75
yum erase ruby ruby-libs
rpm -Uvh http://rbel.co/rbel5
yum install ruby
More info:
http://rbel.frameos.org/
yum install ruby
If this will not install the Ruby for you, add appropriate repository to yum.
If the Ruby version in repositories is outdated, get the source, build, install by yourself.
RPM for CentOS 5.1, x86:
http://repo.premiumhelp.eu/ruby/RPMS/ruby-1.8.6.111-1.i686.rpm
Failing that, the source code is available from the Ruby site, and you can compile and install it:
ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz
"To use with yum, create /etc/yum.repos.d/ruby.repo and add the following:"
[ruby]
name=ruby
baseurl=http://repo.premiumhelp.eu/ruby/
gpgcheck=0
enabled=0
Then:
yum --enablerepo=ruby list RUBY
And:
yum update ruby -y
Another option would be to install ruby with the RVM utility, which lets you easily switch between versions.
Note: On CentOS 5, at least, RVM compiles of Ruby barf because autoconf is too old. There are instructions for fixing this here
you can install ruby and all its dependencies including Gems withi this bash script
The previous repos posted only had the i686 package, this is the repo I'm using for x86_64
[ruby]
name=ruby
baseurl=http://centos.karan.org/el5/misc/testing/x86_64/RPMS/
gpgcheck=0
enabled=0
The yum repo at repo.premiumhelp.eu/ruby/ is DOA.
I found another CentOS-compatable yum repo at rubyworks.rubyforge.org/redhat/ with full instructions here. They explicitly support RHEL/CentOS 4 & 5, but not 6 (yet)

Resources