Rails 3 - no such file to load -- openssl - ruby-on-rails

when running a Rails server, I get the following error:
no such file to load -- openssl
I try a solution I find online. I go to ~/.rvm/src/ruby-1.9.2-head/ext/openssl. I type : ruby extconf.rb, but I get the following:
=== OpenSSL for Ruby configurator ===
=== Checking for system dependent stuff... ===
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for assert.h... yes
=== Checking for required stuff... ===
checking for openssl/ssl.h... no
=== Checking for required stuff failed. ===
Makefile wasn't created. Fix the errors above.
I cannot use make nor make install.

rvm pkg install openssl (older format - rvm package install openssl)
rvm pkg install iconv (older format - rvm package install iconv)
rvm remove 1.9.2
rvm install 1.9.2 -C --with-openssl-dir=$HOME/.rvm/usr,--with-iconv-dir=$HOME/.rvm/usr
Credit to http://www.isnull.com.ar/

check this instruction http://rvm.io/packages/openssl/ - keep in mind that the Quick fix is just one block not the whole page.

You have to install library for openssl/net/http run the following code and then install openssl and iconv.. Following code will work on UBUNTU..
sudo apt-get install libopenssl-ruby1.9.1 this is for ruby 1.9.1.
sudo apt-get install libopenssl-ruby for ruby 1.8.x

first check your rvm having the openssl package. Go to /usr/local/src/rvm/ruby-1.9.2-p290/
then go to ext/openssl.
type ruby extconf.rb
If we found errors like this
enter code here
=== OpenSSL for Ruby configurator ===
=== Checking for system dependent stuff... ===
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for assert.h... yes
=== Checking for required stuff... ===
checking for openssl/ssl.h... no
=== Checking for required stuff failed. ===
Makefile wasn't created. Fix the errors above
Then install apt-get install libssl-dev.Once installed rub ruby extconf.rb.Now the openssl will get installed

For ubuntu, I did the following:
apt-get install libssl-dev
cd ruby-1.9(source directory used to install ruby)/ext/openssl
ruby extconf.rb
make
make install

This solved the problem for me:
rvm pkg install openssl
rvm reinstall 1.9.2 --with-openssl-dir=$rvm_path/usr
And don't forget to change the ruby version to your version you are using. If you have an old rvm you may should update this at first too.

I made
rvm pkg install openssl
rvm reinstall 1.9.3
and done!

You might want to try running ruby-1.9.2-rc2 instead of head?
not sure if it will solve this issue or not, but I did have a lot of problems trying to run under head
pretty sure the the command would look like - rvm install 1.9.2-rc2
you will need to re-install rails again

This error means that your Ruby isn’t compiled with openssl.
Assuming that you use RVM, these are the steps to follow to fix this issue.
1.Install the openssl package
rvm pkg install openssl
2.Remove the Ruby installation you’re using
rvm remove 1.9.3
3.And finally recompile Ruby with openssl
rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm/usr
4.Everything should be working now. Don’t forget to:
rvm use 1.9.3 --default

Try the below steps.
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
if you already have ruby version use
rvm reinstall ruby-2.0.0 --with-openssl-dir=$HOME/.rvm/usr

Related

ERROR: Ruby install aborted due to missing extensions

On Mac Catalina OS, while installing Ruby with rbenv, I am getting this error.
Last 10 log lines:
The Ruby openssl extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
--prefix=/Users/dev/.rbenv/versions/2.5.8
--with-openssl-dir=/usr/local/opt/openssl#1.1
--enable-shared
--with-readline-dir=/usr/local/opt/readline
CC=clang
LDFLAGS=-L/Users/dev/.rbenv/versions/2.5.8/lib
CPPFLAGS=-I/Users/dev/.rbenv/versions/2.5.8/include
EDIT - I have attached the solution which I found and worked for me. I hope this helps others too.
The issue is with OpenSSL. Mac CommandLine Tools is coming with OpenSSL 1.1 whereas you need OpenSSL 1.0. This is the solution for it
$ brew install rbenv/tap/openssl#1.0
$ RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl#1.0)" rbenv install 2.5.8
This will install Ruby 2.5.8. Do not forget to set
rbenv global 2.5.8
to make it work

Unable to require openssl when initialling rails

I have the error below when installing rails on osx maverick. OpenSSL has been installed already. Does anyone know how to fix this issue?
$ gem install rails
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
You may need to update your OpenSSL CA Bundle, per these instructions from chruby about Ruby 2.1.2 which state:
Install 2.1.2
Note: MRI 2.1.2 requires OpenSSL >= 1.0.1.
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.bz2
tar -xjvf ruby-2.1.2.tar.bz2
cd ruby-2.1.2
./configure --prefix=/opt/rubies/ruby-2.1.2
make
sudo make install
Note: OS X users must update their OpenSSL CA cert bundle and properly set ./configure --with-opt-dir to compile against Homebrew's libraries:
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.bz2
tar -xjvf ruby-2.1.2.tar.bz2
cd ruby-2.1.2
./configure --prefix="$HOME/.rubies/ruby-2.1.2" --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml):$(brew --prefix gdbm):$(brew --prefix libffi)"
make
sudo make install
For me, it was enough to just update my OpenSSL CA cert bundle via Homebrew and then reinstall Ruby using ruby-install
brew tap raggi/ale
brew install openssl-osx-ca
ruby-install ruby 2.1.2
After I performed the above steps, the issue stopped presenting itself.
For me... I had tried installing ruby 2.1.2 with ruby-install (since I use chruby for my ruby version manager). I had tried manually installing openssl with homebrew, etc. But I still couldn't get ruby-install to successfully build ruby 2.1.2. I've also had similar issues in the past with installing rubies and ruby-build worked then so I gave I gave it a shot here and it worked! As I understand it, ruby-build is the installer used by rbenv.
What I did was:
rm -rf ~/.rubies/ruby-2.1.2 (This is where my ruby installs are installed at.)
brew remove --force openssl
brew install ruby-build
restart console to be safe
ruby-build 2.1.2 ~/.rubies/ruby-2.1.2
And success! ruby-build seems to be much smarter than ruby-install at successfully installing weird dependencies. I'm done with ruby-install at this point -- it's given me too many problems! (brew remove --force ruby-install)
I've had a similar issue.
A fix to rvm was introduced just yesterday, and it was not yet merged with rvm master branch, so this is how you do it:
rvm get branch /bugfix/3923_set_osx_brew_openssl_compiler_config
rvm install 2.4.0
gem install rails
If that works for you, go to the issue and tell the developer how much you appreciate his effort:
Recently I was struggling with ruby installations due to the recent auto-update in openssl version from 1.0 to 1.1.
I found out that the ruby version < 2.4 does not work with openssl version > 1.0.
I was not even able to revert back the openssl to 1.0 version because other libs has dependencies on it.
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.
secure server is the reason of this issue. You can Install it by using this command:
gem install rails --source http://rubygems.org
by default its using https://rubygem.org as the source for the gem.
$ gem install rails ERROR: While executing gem ... (Gem::Exception) Unable to
require openssl, install OpenSSL and
rebuild ruby (preferred) or use non-HTTPS sources
so we can specify a source, http//:rubygems.org which is a non-HTTPS source.

cannot load such file -- openssl (LoadError)

In OS X in rvm how do I check if openssl is configured properly?
I get the cannot load such file -- openssl (LoadError)
And I have tried everything in Rails 3 - no such file to load -- openssl with no success.
Check what rubies are installed:
rvm list
Then make sure to use one of the installed rubies:
rvm use 1.9.3-p327
And test if openssl is available:
ruby -ropenssl -e "puts :OK"
It will print OK if openssl is enabled, otherwise you will get exception
In case of exception =>
UPDATE:
new version of rvm has improved automation support:
rvm get stable
rvm autolibs enable
rvm reinstall all --force
OLD:
run:
rvm requirements run force
rvm pkg remove
Followed by:
rvm reinstall all --force
This instruction is not OSX specific, it will work on all platforms, although on OSX it will work best with HomeBrew, when it's not installed only list of required software will be shown and you need to install it manually.
Many years later, the solution is changed because of brew upgrading, this works now:
# pull full brew git repo
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow
# generate new brew tap repo
brew tap-new $USER/old-openssl
# extract openssl 1.0.2t forumlar to $USER/old-openssl
brew extract --version=1.0.2t openssl $USER/old-openssl
# install old openssl from $USER/old-openssl repo
brew install openssl#1.0.2t
# reinstall ruby
rvm reinstall 2.3.4 --with-openssl-dir=`brew --prefix openssl#1.0.2t`
Try this.
rvm install ruby-2.0.0-preview1 --with-openssl-dir=$HOME/.rvm/usr --verify-downloads 1
This help me :
https://gist.github.com/Irio/1496746
$ rvm pkg install openssl
$ rvm remove 1.9.3
$ rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr
I uninstalled everything (rvm, rails, ruby, etc) on my macbook.
Installed homebrew
Installed rvm
Ran rvm requirements run force
Ran rvm install rails
rails new sample_app
cd sample_app
Note: source 'https://rubygems.org' is present in Gemfile, openssl is required!
bundle install and it worked!
No need to specify: --with-openssl-dir=$HOME/.rvm/usr
To resolve this, install openssl (preferably using brew).
Update Xcode to the latest version and enable command line installations using it.
Reinstall rvm using
rvm reinstall all
Note that rvm reinstall all --force
will delete all your previous installations of binaries/pkgs done using rvm.
Assuming ruby is already installed, do the following:
rvm cleanup all
rvm reinstall all --force
I got the same error, and the error was fixed by opening new terminal session.
I am using frum ruby version manager.
gem install openssl
worked for me, but nothing has declared depending on the openssl, its weired
Following command solved my issue
note 2.3.4 is the ruby version I am using, change as per your requirements
rvm reinstall 2.3.4 --with-openssl-dir=$rvm_path/usr
Make sure that $rvm_path is properly set, with command echo $rvm_path. If this path is empty, check if your home folder has .rvm folder.
In this case use
rvm reinstall 2.3.4 --with-openssl-dir=~/.rvm/usr

Readline errors prevent me running rails console

My environment is rails 3.1, ruby 1.9.2, rvm, Xubuntu 11.10.
When I try to run the rails console within an app, I am getting require errors pointing at readline.
So I am trying to install readline as a package within RVM, but this is the error I am getting:
Applying patch '/home/rob/.rvm/patches/readline-6.2/patch-shobj-conf.diff'...
ERROR: Error running 'patch -p0 -f < /home/rob/.rvm/patches/readline-6.2/patch-shobj- conf.diff', please read /home/rob/.rvm/log/readline/patch.log
ERROR: Patch /home/rob/.rvm/patches/readline-6.2/patch-shobj-conf.diff did not apply cleanly... back to the patching board :(
The log contains
[2011-10-26 10:16:30] patch -p0 -f < /home/rob/.rvm/patches/readline-6.2/patch-shobj-conf.diff
patching file support/shobj-conf
Hunk #1 FAILED at 157.
1 out of 2 hunks FAILED -- saving rejects to file support/shobj-conf.rej
I've tried
$ rvm pkg install readline
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-readline-dir=$rvm_path/usr
And
$ cd $HOME/.rvm/src/ruby-1.9.2-p0/ext/readline
$ ruby extconf.rb
$ make install
The latter gives me
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
Running 'rails server' works, so I think the problem is just with readline.
Can anyone point me in the right direction.
Ran into the same problem on Ubuntu 10.0.4 and managed to fix it with:
rvm uninstall 1.9.2
sudo apt-get install libreadline-dev
rvm install 1.9.2 --with-readline-dir=/usr/include/readline
I've reinstall ruby 1.9.2 pointing at my system version of readline using this command:
rvm install 1.9.2 --with-readline-dir=/usr/include/readline
That seems to have fixed my problem and everything is now working.
Rob
Also worth noting that a matching issue exists on the rvm github site and it should be fixed soon:
https://github.com/wayneeseguin/rvm/issues/515
Ubuntu 11.10.
For me the following worked:
First install rvm.
Then install everything from rvm requirements
Then install 1.9.3 or whatever.

Ruby 1.9.2 and Rails 3 cannot open rails console

[gkaykck#main myApplication]$ rails console
/usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError)
from /usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:20:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:20:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have installed rails 3 on ruby 1.9.2p136, which is ok i guess. But i cannot start rails console and it gives me the error i copied. The apps worked great with ruby 1.8.7 and i never saw an error like this.
Any ideas what it could be?
Apparently ubuntu and ruby don't always catch dependencies like they should.
From the first google hit (yeah, I clicked on this stack-overflow in place #2 before checking out the first result.)
Navigate to the Ruby source and enter:
sudo apt-get install libreadline5-dev
cd ext/readline
ruby extconf.rb
make
sudo make install
So, if you're on another distro, make sure you install readline somehow (source/package), then run make/install on extconf from the source. I tried what gkaykck suggested of course but got this without readline already on my system.
$ ruby extconf.rb
checking for tgetnum() in -lncurses... no
checking for tgetnum() in -ltermcap... no
checking for tgetnum() in -lcurses... no
checking for readline/readline.h... no
checking for editline/readline.h... no
Recipe for those who use rvm:
rvm pkg install readline
rvm remove 1.9.3
rvm install 1.9.3 --with-readline-dir=$rvm_path/usr
In more details about it on https://rvm.io/packages/readline/
If you want another solution to this problem do this.
sudo apt-get install libreadline6
Then in your gem file add:
gem 'rb-readline'
Then
bundle install
And you should be all set.
I'd recommend using rvm (Ruby Version Manager) to manage your different versions of Ruby and switch between them. It does a pretty good job of compiling the various versions for you too. You can even create per-directory .rvmrc files to tell rvm what version of ruby to use in which directory (as well as use per-project gem sets if you want!)
First of all uninstall every ruby version you have.
After that display rvm requirements:
rvm requirements
You will get something like:
Requirements for Linux ( DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION="Ubuntu 11.10" )
NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
This is the *original* / standard Ruby Language Interpreter
'ree' represents Ruby Enterprise Edition
'rbx' represents Rubinius
bash >= 4.1 required curl is required git is required (>= 1.7 for
ruby-head) patch is required (for 1.8 rubies and some ruby-head's).
To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head), then you
must install and use rvm 1.8.7 first.
Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
ruby: /usr/bin/apt-get install build-essential 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
ncurses-dev automake libtool bison subversion
# For JRuby, install the following:
jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk
# For IronRuby, install the following:
ironruby: /usr/bin/apt-get install curl mono-2.0-devel
Install all dependencies via apt-get.
After that install ruby 1.8.7. This version is required if you plan to use ruby 1.9.x
Now you can install ruby 1.9.3:
rvm pkg install readline
rvm remove 1.9.3
rvm install 1.9.3 --with-readline-dir=$rvm_path/usr
Note that you dont even need to install readline package via rvm if you had installed it using apt-get.
With CentOS 6:
Remember we are working from the ruby install dir, for me it was:
/opt/ruby-1.9.3-p194/ext/readline
If you see the following output, then readline is not installed:
$ ruby extconf.rb
checking for tgetnum() in -lncurses... no
checking for tgetnum() in -ltermcap... no
checking for tgetnum() in -lcurses... no
checking for readline/readline.h... no
checking for editline/readline.h... no
To install with RPM:
yum install readline-devel
Then build it:
ruby extconf.rb
make
sudo make install
Adding in the Gemfile
gem 'rb-readline'
and then bundle install
did the trick for me
Solution is to go to the source folder you compiled ruby => ext => readline than
ruby extconf.rb
make
sudo make install
If you're using RVM you can re-make readline. This fixed the issue for me. Instructions here:
no such file to load -- readline (Load Error)
use rvm remove to remove all ruby installed.
do a "which ruby" if you still get something, you need to reinstall rvm then install ruby using rvm.

Resources