Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rbenv install not downloading ruby version

Installing ruby version with rbenv rbenv install -lreturns the proper list. However

$ rbenv install 2.3.4 -v

fails on the download, even though it can be downloaded via a browser. My hunch about an improper version of openssl (due to some distant memory of having such issues - tls version? - in the past) is supported in verbose mode:

ruby-build: use openssl from homebrew 
/var/folders/kV/kVDOSPkcEuqSVnTjenAVRE+++TI/-Tmp-/ruby-build.20170601122915.1010 ~ Downloading ruby-2.3.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.bz2 
curl: (35)    error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version 
error: failed to download ruby-2.3.4.tar.bz2

how to overcome? can I point rbenv to use the downloaded tarball?

like image 292
Jerome Avatar asked Jun 01 '17 10:06

Jerome


1 Answers

The reason is because rbenv use old system curl and old system openssl with it, which knows nothing about protocols TLS v 1.1-1.3. For me, installing new version of curl and openssl with brew did the work:

brew install [email protected]
brew install curl

Then add installed curl to your PATH (before default path, which is /usr/bin), and ensure that openssl of actual brew's version is also there (add this to your ./bash_profile or ./zshrc or etc):

export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/curl/bin:$PATH"

You can make sure after relaunch of terminal that latest versions of this programs will be used by trying

which -a openssl
which -a curl
openssl version -a
curl -V

First two commands should output all paths with the programs, but top ones should be brew versions. Last two commands should show latest versions of programs (1.1.0f and 7.55 for me now). Now try

rbenv install [version]

Works on MacOS Sierra with enabled SIP.

like image 114
SkipIntro Avatar answered Oct 04 '22 20:10

SkipIntro