unable to install ruby 2.3.8 in macos m1 - ruby

Unable to install ruby 2.3.8 in MacOS M1 chip below is the error I'm getting. Tried multiple ways
trial 1: rvm install 2.3.4 -C --with-openssl-dir=/opt/homebrew/opt/openssl#1.0/bin/openssl
Error running '__rvm_make -j8',
Still nothing works. Any help would be appreciate

You can download an old version of openssl and bind it to the ruby installation.
Download: https://github.com/openssl/openssl/releases/tag/OpenSSL_1_0_2u
$> tar -xzf openssl-OpenSSL_1_0_2u.tar.gz
$> cd openssl-1.0.2u
$> ./Configure darwin64-x86_64-cc --prefix=/usr/local/opt/openssl#1.0
$> make
$> make test
$> sudo make install
And then install ruby using:
$> arch -x86_64 rvm install 2.3.8 --with-openssl-dir=/usr/local/opt/openssl#1.0
Source: https://github.com/rvm/rvm/issues/5033

Install openssl 1.0 with this brew tap (source)
brew install nutcracker/tap/openssl#1.0
then just install ruby using:
rvm install 2.3.8 --with-openssl-dir=/opt/homebrew/Cellar/openssl#1.0/1.0.2u

Related

How to "recompile Ruby with OpenSSL support" using RVM?

After installing Ruby 2.3.8 via RVM I get the following error when running bundle:
You must recompile Ruby with OpenSSL support or change the sources in your Gemfile
How do I recompile Ruby with OpenSSL support?
My Solution for this:
Just run
1: brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/8c9b113bc6812dc74c598c8f860017e42fba8d78/Formula/openssl.rb
2: rvm install 2.3 --with-openssl-lib=/usr/local/opt/openssl/lib --with-openssl-include=/usr/local/opt/openssl/include
(if rvm is already installed, use reinstall instead of install.)
For rvm on MacOS Mojave
In my case, the installer fails because it is using obsolete parts in the new version of openssl. This has worked for me:
Go to the "homebrew-core" folder and get back the old openssl gem(1.0.2t)
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
git show 8b9d6d688f483a0f33fcfc93d433de501b9c3513:Formula/openssl.rb >> Formula/openssl\#1.0.2t.rb
Enter the file and rename the class "Openssl" to "OpensslAT102t"
brew edit Formula/openssl\#1.0.2t.rb
Install it with brew
brew install openssl#1.0.2t
Once installed, force rvm to use the installed version of ssl
# Install 2.3.8
rvm install 2.3.8 --disable-binary --with-openssl-dir=`brew --prefix openssl#1.0.2t`
# Or reinstall
rvm reinstall 2.3.8 --disable-binary --with-openssl-dir=`brew --prefix openssl#1.0.2t`

Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

I'm attempting to install jekyll and I've encountered an error. I'm running Mac OS X 10.11.4 (El Capitan).
$gem install jekyll
ERROR : While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
$gem source -l
https://ruby.taobao.org
$which openssl
/usr/local/bin/openssl
I welcome your suggestions how to resolve this error.
Newer versions of OSX deprecated openSSL, leaving many dependencies broken. You need to reinstall ruby, but specify exactly where your openSSL libraries are. If you're using rvm then that looks like:
rvm reinstall 2.3.0 --with-openssl-dir=/usr/local/opt/openssl
If you're using homebrew, then a quick shortcut to where your libraries are is:
brew install openssl
rvm reinstall 2.3.0 --with-openssl-dir=`brew --prefix openssl`
Method 1 (Install OpenSSL)
Type all these commands in your Terminal (OSX) just to be extra sure you've done everything:
rvm get stable
brew update
brew doctor
brew install openssl
rvm install ruby-2.4 (or whatever version)
rvm use ruby-2.4 (or whatever version)
rvm gemset create jekyll
gem install jekyll
Finally, you need OpenSSL installed before you compile Ruby before you install Jekyll (or other gems)!
Method 2 (Reinstalling Ruby)
Newer versions of OSX deprecated openSSL.
You need to reinstall Ruby!
RVM with OpenSSL
rvm reinstall 2.3.0 --with-openssl-dir=/usr/local/opt/openssl
With the latest RVM version
rvm get stable
rvm reinstall ruby-2.3.0
homebrew and OpenSSL
brew install openssl
rvm reinstall 2.3.0 --with-openssl-dir=`brew --prefix openssl`
You just need to set this env variables so your compiler has the correct path for openssl libs (if using Homebrew on macOS, try brew info openssl to see this info):
$ export LDFLAGS=-L/usr/local/opt/openssl/lib
$ export CPPFLAGS=-I/usr/local/opt/openssl/include
# For pkg-config to find this software you may need to set:
$ export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
Then reinstall your ruby (rvm reinstall ruby-version)
brew install openssl
brew info openssl # do the suggested options
$ export LDFLAGS=-L/usr/local/opt/openssl/lib
$ export CPPFLAGS=-I/usr/local/opt/openssl/include
# For pkg-config to find this software you may need to set:
$ export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
rvm reinstall <version> --with-openssl-dir=`brew --prefix openssl`
For ubuntu 22.04. Ruby will not compile with openssl v3. Which is the openssl if you install it using brew.
Do this:
brew install openssl#1.1
rvm install 3.0.2 --with-openssl-dir=`brew --prefix openssl#1.1`
To solve this issue, you should install OpenSSL version 1.1, and link ruby to it while installing process.
Here the commands worked fine with me (macOS):
// install openssl#1.1
brew install openssl#1.1
// export PKG_CONFIG_PATH variable
export PKG_CONFIG_PATH=/opt/homebrew/opt/openssl#1.1/lib/pkgconfig
// reinstall your ruby version with openssl 1.1 dir
rvm reinstall 3.0.4 --with-openssl-dir=/opt/homebrew/opt/openssl#1.1
Considering the other answers related to openssl, we can see the same error yet when we try to execute as a superuser in some cases, as follows:
filipe#FILIPE:~$ sudo gem install bundler
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
Without superuser permissions, we can see a different behavior, a successful one, as follows:
filipe#FILIPE:~$ gem install bundler
Fetching: bundler-1.14.6.gem (100%)
Successfully installed bundler-1.14.6
Parsing documentation for bundler-1.14.6
Installing ri documentation for bundler-1.14.6
Done installing documentation for bundler after 4 seconds
1 gem installed

troubles with RVM and OpenSSL

Trying to set up a new macbook for a colleague. Not going well.
First I install OpenSSL:
Heathers-MacBook-Pro:~ heather$ rvm pkg install openssl
Fetching openssl-1.0.1c.tar.gz to /Users/heather/.rvm/archives
######################################################################## 100.0%
Extracting openssl to /Users/heather/.rvm/src/openssl-1.0.1c
Configuring openssl in /Users/heather/.rvm/src/openssl-1.0.1c.
Compiling openssl in /Users/heather/.rvm/src/openssl-1.0.1c.
Installing openssl to /Users/heather/.rvm/usr
Please note that it's required to reinstall all rubies:
rvm reinstall all --force
Updating openssl certificates
Then I try to install ruby with openssl...
Heathers-MacBook-Pro:website heather$ rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm/usr
Fetching yaml-0.1.4.tar.gz to /Users/heather/.rvm/archives
Extracting yaml to /Users/heather/.rvm/src/yaml-0.1.4
Configuring yaml in /Users/heather/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/heather/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/heather/.rvm/usr
Installing Ruby from source to: /Users/heather/.rvm/rubies/ruby-1.9.3-p392, this may take a while depending on your cpu(s)...
ruby-1.9.3-p392 - #downloading ruby-1.9.3-p392, this may take a while depending on your connection...
ruby-1.9.3-p392 - #extracting ruby-1.9.3-p392 to /Users/heather/.rvm/src/ruby-1.9.3-p392
ruby-1.9.3-p392 - #extracted to /Users/heather/.rvm/src/ruby-1.9.3-p392
ruby-1.9.3-p392 - #configuring
ruby-1.9.3-p392 - #compiling
ruby-1.9.3-p392 - #installing
Removing old Rubygems files...
Installing rubygems-1.8.25 for ruby-1.9.3-p392 ...
Installation of rubygems completed successfully.
Saving wrappers to '/Users/heather/.rvm/bin'.
ruby-1.9.3-p392 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.3-p392 - #importing default gemsets, this may take time ...
Install of ruby-1.9.3-p392 - #complete
Heathers-MacBook-Pro:website heather$ bundle update
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.
btw, the gem file says "source https://rubygems.org"
ideas?
OP actually saved my day!
In my case:
$ rvm pkg install openssl
$ rvm remove 2.4
$ rvm install 2.4 --with-openssl-dir=$HOME/.rvm/usr
$ gem install bundler
It's well described on ArchLinux wiki:
Ruby versions older than 2.4 require OpenSSL 1.0 but RVM will try to build them with OpenSSL 1.1.
So you can do (easiest):
$ rvm pkg install openssl
$ rvm reinstall 2.3.5 --with-openssl-dir=$HOME/.rvm/usr
You can see more solutions on ArchLinux wiki.
Try this:
rvm get head
rvm pkg remove
rvm requirements run # if brew gives you warnings about formulas to install, run "brew install" for each before moving on.
rvm reinstall [the version you need (i.e: 2.0.0)]
Installing Ruby 2.2 on macOS Mojave (10.14.2) with Homebrew.
Install Homebrew
brew install openssl
rvm install 2.2 --with-openssl-dir=/usr/local/opt/openssl
Don't use rvm pkg it's deprecated, use rvm autolibs enabled.
Here's how I installed rvm and ruby 2.3 on a mac with Catalina. The version of rvm installed was 1.29.9. OpenSSL 1.0.2 (downgrade) had to be installed. Note the "ipv4" in the gpg command.
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
Download openssl 1.0.2 at https://www.openssl.org/source/
tar -xzf openssl-1.0.2t.tar.gz
cd openssl-1.0.2t
./Configure darwin64-x86_64-cc --prefix=/usr/local/opt/openssl#1.0
make
make test
sudo make install
rvm install 2.3.3 --with-openssl-dir=/usr/local/opt/openssl#1.0
ruby -v
ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
>> OpenSSL 1.0.2t 10 Sep 2019
On MacOS 10.12.2 installing openssl via brew, won't work. To fix it, run:
export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig:/usr/local/lib/pkgconfig
And then install Ruby via rvm.
EDIT:
More information about the reason behind the problem here.
For those who have issue with openssl 1.1 and Ruby 2.3 via RVM on Mac Mojave, you could try following commands. The problem is Ruby 2.3 is not compatible with openssl 1.1
rvm pkg install openssl
PKG_CONFIG_PATH=$HOME/.rvm/usr/lib/pkgconfig rvm reinstall 2.3.3 --with-openssl-dir=$HOME/.rvm/usr
Here is what 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
Cheers!
For older version of ruby 2.2.10 on MacOS High Sierra 10.13.6 the only thing worked for me was:
switching to older OpenSSL version
brew switch openssl 1.0.2s
Than reinstalling ruby using --with-openssl-dir
rvm reinstall 2.2.10 --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s
So this worked for me:
rvm pkg install openssl
rvm reinstall all --force
I also had rvm autolibs rvm_pkg for readline support.
openssl version: 1.0.2k
This worked for me:
brew reinstall openssl
For rvm on MacOS
First, check and see if you have openssl installed. You should see something like this:
$ brew --prefix openssl
/usr/local/opt/openssl#1.1
If openssl is not installed, do so.
$ brew install openssl
$ brew unlink openssl
$ brew link --force openssl
If you have more than one openssl installed, consider removing all but one to make your life easier.
$ brew cleanup openssl
$ brew list --versions openssl
$ brew uninstall <unwanted-openssl-version-here>
Now reinstall the ruby version, specifying the desired openssl path.
$ rvm reinstall <your-version-here> --with-openssl-dir=`brew --prefix openssl`
Finally, verify that your ruby was compiled with the same openssl it was linked to. If you see the same version twice, you should be all set.
$ ruby -ropenssl -e'puts OpenSSL::OPENSSL_VERSION, OpenSSL::OPENSSL_LIBRARY_VERSION'
OpenSSL 1.1.1d 10 Sep 2019
OpenSSL 1.1.1d 10 Sep 2019
If later you install other versions of ruby, you will need to pass the same --with-openssl-dir argument. Alternatively, I believe you can set the following variables in your bash profile.
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix openssl)/lib/pkgconfig"
export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix openssl)/lib"
If the above doesn't work, remove the lines from your bash profile and just use the --with-openssl-dir argument as above.
Ref: https://github.com/rvm/rvm/issues/4562
Ref: https://bugs.ruby-lang.org/issues/12630
For anyone using macports I found the following got things working:
$ sudo port install openssl11
$ PKG_CONFIG_PATH="/opt/local/libexec/openssl11/lib/pkgconfig" rvm reinstall 2.7.5 --with-openssl-dir='/opt/local/libexec/openssl11'
For windows (using Ubuntu WSL), I need to use the different path where openssl is found.
$ rvm pkg install openssl
$ rvm remove 2.4
$ rvm install 2.4 --with-openssl-dir=/usr/local/rvm/usr
$ gem install bundler
Anyone on Mac using homebrew can use this command which worked for me.
rvm install 2.7.7 --with-openssl-dir=$(brew --prefix openssl)/lib

Installing Ruby via rbenv fails

Problem: I installed ruby, but it is not recognized correctly.
I'm following the deploying to VPS: https://github.com/railscasts/335-deploying-to-a-vps
I am setting my server on ubuntu 12.04 LTS to deploy my rails app. I'm following the railscast on deploying to a VPS, and trying to install ruby through rbenv. It seemed everything was installed correctly, but when I tried to check the ruby version, it gave me errors. The following are the commands that I ran.
deployer#max:~$ rbenv install 1.9.3-p125
Downloading yaml-0.1.4.tar.gz...
-> http://cloud.github.com/downloads/sstephenson/ruby-build-download-mirror/36c852831d02cf90508c29852361d01b
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /home/deployer/.rbenv/versions/1.9.3-p125
Downloading ruby-1.9.3-p125.tar.gz...
-> http://cloud.github.com/downloads/sstephenson/ruby-build-download-mirror/e3ea86b9d3fc2d3ec867f66969ae3b92
Installing ruby-1.9.3-p125...
Installed ruby-1.9.3-p125 to /home/deployer/.rbenv/versions/1.9.3-p125
Downloading rubygems-1.8.23.tar.gz...
-> http://cloud.github.com/downloads/sstephenson/ruby-build-download-mirror/178b0ebae78dbb46963c51ad29bb6bd9
Installing rubygems-1.8.23...
Installed rubygems-1.8.23 to /home/deployer/.rbenv/versions/1.9.3-p125
deployer#max:~$ rbenv global 1.9.3-p125
deployer#max:~$ ruby -v
'ruby' program can be found in the following packages:
* ruby1.8
* ruby1.9.1
How do I solve this?
You don't need to use rbenv to install a specific version of Ruby. Instead use ruby-build to install 1.9.3-p125 into /usr/local:
ruby-build 1.9.3-p125 /usr/local/
Or, install Ruby manually:
# Compile Ruby (instead of rbenv)
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
sudo make install
sudo gem install bundler --no-ri --no-rdoc
Maybe you are missing
eval "$(rbenv init -)";
in your shell config
You should restart the shell to allow rbenv to find the new Ruby
$ exec $SHELL
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]

Installing libyaml for ruby on a mac osX (Lion)

I am getting this error message:
"It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby."
I have tried entering this command: rvm pkg install libyaml
and I am getting this error message:
"Fetching yaml-0.1.4.tar.gz to /Users/luke/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/luke/.rvm/src
Error running 'tar xmzf /Users/luke/.rvm/archives/yaml-0.1.4.tar.gz -C
/Users/luke/.rvm/src ',
please read /Users/luke/.rvm/log/yaml/extract.log
Configuring yaml in /Users/luke/.rvm/src/yaml-0.1.4.
Error running ' ./configure --prefix="/Users/luke/.rvm/usr" ',
please read /Users/luke/.rvm/log/yaml/configure.log
Compiling yaml in /Users/luke/.rvm/src/yaml-0.1.4.
Error running 'make ', please read /Users/luke/.rvm/log/yaml/make.log
Database file /Users/luke/.rvm/config/packages does not exist."
Does anyone know what I am doing wrong? Thanks!
The current release [was] LibYAML: 0.1.4 (2011-05-30) [in 2012 when I answered this question].
Download the source package: http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz.
To build and install LibYAML, run
$tar zxf yaml-0.1.4.tar.gz
$cd yaml-0.1.4
$ ./configure
$ make
$ make install
OR just:
$brew install libyaml
Next,
$brew install ruby
Good luck.
This worked for me:
rvm remove 1.9.3
download http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
cp Downloads/yaml-0.1.4.tar.gz .rvm/archives/
rvm install 1.9.3
Try this...
Open a new terminal window and:
cd .rvm/src
sudo rm -rf yaml*
(supply your credentials)
cd ~
rvm pkg install libyaml
Installing ruby with rvm for mac osx, use autolibs to install libyaml and first uninstalling libyaml helps.
This worked for me:
brew uninstall libyaml
rvm autolibs enable
rvm reinstall ruby-2.1.1

Resources