Unable to require openssl, install OpenSSL and reb

2019-03-08 00:40发布

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.

4条回答
Luminary・发光体
2楼-- · 2019-03-08 00:51

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)

查看更多
该账号已被封号
3楼-- · 2019-03-08 00:53

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
查看更多
乱世女痞
4楼-- · 2019-03-08 00:58

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`
查看更多
看我几分像从前
5楼-- · 2019-03-08 01:00

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`
查看更多
登录 后发表回答