cannot load such file -- openssl (LoadError) - ruby-on-rails

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

Related

ERROR: While executing gem ... (Gem::Exception) OpenSSL is not available

I get this openssl error when trying to install/update any gem, although I have openSSL installed through brew install openssl.
This can be frustrating but there is a way to address this problem.
To address this problem, you need to:
Install openssl: brew install openssl
Using whatever package manager you use for ruby (rbenv, rvm, frum), reinstall the ruby version you need to work with, using the cli option for specifying the openssl directory to be used by the ruby version being installed.
For rvm that means:
rvm reinstall 2.3.0 — with-openssl-dir=`brew —-prefix openssl`
For frum:
frum uninstall <ruby version>
frum install <ruby version> --with-openssl-dir=<ssl_dir> # Specify the OpenSSL directory
This guide was geared towards MacOS. Similarly, you should reinstall ruby with the right cli options on whichever operating system you are using.

RoR: Could not load OpenSSL (after Apple's Bash fix today)

Hoping someone can help explain and or advise me on this error I'm catching after i tried to re-install rails via rvm after running Apple's bash shellshock fix today.
I upgraded to OSX 10.9.5 mav and ran the Bash Shellshock, then my RoR apps needed rails re-installed. When I try to bundle install I get the following:
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.
Remove the Ruby version you installed with RVM
$ rvm remove ruby-2.1.2
and reinstall it
$ rvm install ruby-2.1.2

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.

I can't install rails on OSX 10.7.5

Whenever I run
sudo gem install rails
I get the following output:
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
RVM version: rvm 1.18.14
and Ruby is 2.0.0p0
you need to reinstall your rubies:
rvm get head --autolibs=3
rvm pkg remove
rvm reinstall all --force
the new autolibs supporrt will take care of updating dependencies and including them in ruby
Do you have Homebrew installed on your system? If so, try
brew install openssl
in the command line.
hmm, you have rvm but why you need sudo?I thought rvm is in sandbox mode . Anyway, the error just means it can't find ssl path. First, make sure you have openssl installed. If not then you need to install it(brew, macport etc) or rvm pkg install openssl and let rvm manage its path(you have rvm already). After that, you will need to reinstall ruby. RVM guide is here
You don't use sudo. sudo is ONLY used for doing a multi-user install, and only then during the initial installation, and adding your user to the rvm group (if the installer did not do it for you which usually indicates you did the install wrong in the first place)
I figured it out!
So First I removed everything to do with RVM as suggested in some of the answers. Rebooted. Installed the latest Version of Xcode and the command line tools from Xcode (Xcode-prefereces-downloads). Then rebooted again, and finally used RailsInstaller. Once I used that rails was back on and all is good in the world. Thanks for the help everyone.

no such file to load -- readline

I am getting the following error:
$script/console
Loading development environment (Rails 2.2.2)
/opt/ruby-enterprise-1.8.6-20080709/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
Where can i get the file and what directory should it go in?
Thanks!
The readline module is normally part of the Ruby package itself.
Did you manually build your Ruby install? If so, you want to make sure libreadline and its headers are installed, and build again.
On Debian/Ubuntu:
apt-get install libreadline-dev
Or on RHEL/CentOS, try
yum install readline-devel
Update:
You are using a very old release of Ubuntu. If you want to keep using it, open /etc/apt/sources.list in a text editor, and change all occurrences of archive.ubuntu.com to old-releases.ubuntu.com. Then, run apt-get update and try the above again.
I urge you to consider updating your installation, though. Ubuntu 7.10 hasn't seen security updates in quite a while, and using it in production is not recommended. Even if it's not a production machine, there's a good chance you'll run into further problems because of old versions of certain libraries/dependencies.
You need to install the ncurses and readline libraries.
On Ubunutu you could do
sudo apt-get install libreadline5-dev libncurses5-dev
and then you will have to recompile readline which comes with your ruby source
cd <ruby-src-dir>/ext/readline
ruby extconf.rb
make
sudo make install
If you are using RVM you could simply do
rvm package install readline
EDIT:
On newer RVM versions, this last command is
rvm pkg install readline
Add the following line to your Gemfile and run bundle update
gem 'rb-readline'
credits to similar question/answer at install ruby 1.9.3 using rvm on ubuntu
This easiest way to get relief from this problem,
just add to your Gemfile:
gem 'rb-readline'
And then run bundle install
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!
EDIT
If you can't find the requirements option update your rvm.
rvm update --head # older rvm
or use rvm upgrade
Maybe this is a bullshit answer, but I ran into this problem today after upgrading postgres from 9.5.3 to 9.6, along with which homebrew upgraded readline from 6.something to 7. I ended up rolling back my postgres to 9.5.3 and that resolved the issue.

Resources