Problem when installing Ruby using RVM - ruby

I am having a hard time trying to reinstall Ruby (1.9.2-p136) on my ubuntu machine, using RVM.
Basically I just do:
rvm install 1.9.2-p136
And during the Compiling step, it fails with the following error message:
(NoMethodError) undefined method
`set_encoding' for RDoc::Parser:Class
I tried to look for this on Stackoverflow and Google but it didn't help!
Any idea?
Thanks!
EDIT:
To be clear, I am not using Ubuntu but Linux Mint 9 which is based on Ubuntu 10.04.

Well, oddly enough, RDoc was rev'd last week to a new version. So, I suspect you're running into a snag with it, maybe Ruby 1.9.2-p136, and maybe RVM.
I'd recommend contacting the author of RVM; You can email him at the address that appears when you do rvm -v. Include the output of rvm info.
I'll do an install to a VM on my machine here and see how it goes. I have the same Ruby version, but it's been in place since it came out, so when RDoc updated there was an existing Ruby. I have the most recent Mint, which I assume is 9, based on Ubuntu 10 I think it said.
EDIT:
I just built a Mint 10 VM, then installed rvm, then installed 1.8.7-p330 and 1.9.2-p136. Neither had any problems.
One thing I didn't do, that Wayne Seguin told me is important, is to rvm notes after installing it, before installing Ruby. That will display any OS-specific things needed. For instance, on Mint 10 it says:
dependencies:
For RVM
rvm: bash curl git
For Ruby (MRI & ree) you should install the following OS dependencies:
ruby: /usr/bin/aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
EDIT:
An additional thing you might run into is a zlib warning when installing gems, which is handled on the RVM site in Zlib

I don't know what your problem is, but I've had to install rails to a couple of ubuntu machines and it was a nightmare compiling everything. I recently found:
http://thechangelog.com/post/2857400260/railsready-setup-script-to-get-ruby-and-rails-running
This is the only way I would install rails in ubuntu.

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.

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.

problems installing latest ruby version

I need some help here with RVM and installing the latest version of rails on a debian server. please note im not a linux programmer so you'll have to spell out everything for me.
basically i'm trying to upgrade to the newest version of ruby. I'm trying to install that on a debian server that I connect to via VPN. I'm trying to use RVM so far, but when i run the RVM install 1.9.3 from my debian bash prompt it says there are no binary available for that version, then proceeds to try and grab the source from online which fails (probably due to the firewall). basically when it grabs the source folder from online, it grabs a corrupted hunk of junk. I tried downloading the source package myself and if i click the link on the ruby site it blocks it. If i use wget it appears to download it, but the md5 doesnt match and i cant untar it the thing. it says gzip: stdin: the file is not in gzip format.
So! I neeeedddsss to help. What I was thinkin was getting the binary rubies for 1.9.3.. but I'm unsure how really.. I downloaded the tar.gz file on my windows and used winSCP to move it over, and then I can use untar the thing fine.. and then i have an unzipped folder that is the source from the site.. but im unsure where to go from there.. apt-get install doesnt seem to recognize the tar.gz or the untarred folder.. i tried rvm mount and specifying the path to ruby.exe file (ruby-1.9.3-p327/bin/ruby) but then it says unrecognized command line argument and i should see the usage..
Any advice out there? (preferably without 3rd party programs or stuff other the RVM)
thanks
Because you're a novice, I suggest skipping RVM unless you know you need it.
Debian has great way to install Ruby and make it available for all of the system users:
sudo apt-get install ruby1.9.3
You will use the root password to install it this way.
To verify it worked:
ruby -v
That should print out something like this:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
In case you want to install ruby using rvm: Just execute the commands in the same sequence..
$ sudo apt-get install curl git-core ruby
$ \curl -L https://get.rvm.io | bash -s stable
$ sudo apt-get install libssl-dev
$ source ~/.rvm/scripts/rvm
$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
$ rvm install 1.9.3
--give the password for sqlserver or you can just press enter.
$ gem install rails
You have ROR setup now!
Reading back on my questions, I remember now, it WAS the firewall. The firewall where I was working at the time didn't allow me to download ruby source properly. It was downloading, but not actual source, corrupted source. So, I did it at home and it worked fine.
Just thought I'd pop this in here in case anyone ever finds it when problems installing ruby.

Readline not working in rvm - Ubuntu 11.10

I am using rvm on my ubyntu 11.10. My readline is not working, I tried ruby extconf.rb but it is not passed. Output is bellow:
$ ruby extconf.rb
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no
checking for readline() in -ledit... no
checking for editline/readline.h... no
I tried installing libncurses5-dev & libreadline5-dev
$ sudo apt-get install libncurses5-dev libreadline5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libreadline5-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
libreadline-gplv2-dev:i386 lib64readline-gplv2-dev:i386 libreadline-gplv2-dev
E: Package 'libreadline5-dev' has no installation candidate
What is the problem here? Can anyone help?
Same issue as here Readline errors prevent me running rails console
Under ubuntu you can use the system readline installation.
rvm uninstall ${YOURUBYVERSION}
sudo apt-get install libreadline-dev
rvm install ${YOURUBYVERSION} --with-readline-dir=/usr/include/readline
Substitute ${YOURUBYVERSION} with your desired ruby version.
I got the solution:
Run the command
rvm requirements
It shows the requirements and dependencies. Install those and reinstall the ruby on rvm
rvm remove 1.9.2
rvm install 1.9.2
It works!
For some reason I can't comment on #zzeroo's answer, but I want to draw attention to the fact that he's using
--with-readline-dir=/usr/include/readline
instead of
--with-readline-dir=$rvm_path/usr
I was banging my head against the wall for a long time and changing this fixed it for me.
Have you tried:
rvm pkg install readline
Then install ruby through RVM --with-readline-dir=$rvm_path/usr?
http://beginrescueend.com/packages/readline/
FWIW, I'd suggest giving rbenv + ruby-build a go, if you've never considered it. A lot less headaches than with RVM.
I've googled for a couple days, but no answers helps me, so my solution was:
Fully remove rvm How to remove rvm
Remove all ruby packages. First, find out which packages do you have:
dpkg -l | grep ruby
then make
sudo apt-get purge {PACKAGE}
where {PACKAGE} is package you want to remove ( for me there were ruby ruby1.8 ruby1.9.1 )
Then I made fresh installation of RVM Install RVM and installed ruby 1.9.2 with
rvm install 1.9.2
Now it should work!
I tried everything, but it didn't work. I had to do rvm implode (after having all the requirements installed) and then rvm install 1.8.7; rvm install 1.9.3 and it wor

Error installing Ruby 1.8.6 and openssl using RVM under Snow Leopard

I'm trying to install ruby 1.8.6 on Snow Leopard using rvm.
I tried:
rvm install ruby-1.8.6-p111
and got an error explaining make couldn't find openssl.
make[1]: *** [openssl_missing.o] Error 1
I then tried:
rvm install ruby-1.8.6-p111 -C --with-openssl-dir=/System/Library/OpenSSL
(Snow Leopard seems to come with openssl and this seems to be the location)
In the logs I get the same error.
As per http://rvm.beginrescueend.com/packages/openssl/ I then tried to install openssl using rvm like so:
rvm package install openssl
This time, in configure.error.log I get:
[2010-07-07 07:54:28] ./Configure os/compiler darwin-i386-cc -I/Users/craig/.rvm/usr/include -L/Users/craig/.rvm/usr/lib --prefix=/Users/craig/.rvm/usr zlib no-asm no-krb5 shared
target already defined - os/compiler (offending arg: darwin-i386-cc)
I'd really appreciate any suggestions.
I know it doesn't help you much, but thanks for the pointer to "rvm package install openssl" -- it fixed the original openssl_missing.o error for me and everything worked fine from there... eventually.
Here's what I ended up doing to get rvm to work on my laptop, minus some silly MacPorts fiddling because I had some old PowerPC binaries installed in /usr/local/lib.
rvm package install openssl
rvm package install readline
rvm package install iconv
sudo port install ncurses
sudo port install libyaml
sudo port install zlib
rvm install 1.9.2-head -C "--with-openssl-dir=$HOME/.rvm/usr --with-libyaml-dir=/opt/local --with-readline-dir=$HOME/.rvm/usr --with-iconv-dir=$HOME/.rvm/usr"
Ha! I just tried to install rvm on my work computer and ran into your original problem!
Looks like there was a bug in ~/.rvm/scripts/package. Try running
rvm update --head
or
rvm get latest
to get the latest version from git and try again.

Resources