7

So I am following this tutorial: https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-macos-for-development/15772 but when I use bundle install it gives me this error:

An error occurred while installing openssl (2.2.0), and Bundler cannot
continue.
Make sure that `gem install openssl -v '2.2.0' --source 'https://rubygems.org/'`
succeeds before bundling.

along with

Installing openssl 2.2.0 with native extensions
Installing cppjieba_rb 0.3.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension

but why do I get this?

Running gem install openssl -v '2.2.0' --source 'https://rubygems.org/' gives me...

Building native...
ERROR:  Error installing openssl:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/openssl-2.2.0/ext/openssl
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210225-70291-10x2bpm.rb extconf.rb
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for openssl/ssl.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
    --with-openssl-dir
    --with-openssl-include
    --without-openssl-include=${openssl-dir}/include
    --with-openssl-lib
    --without-openssl-lib=${openssl-dir}/lib
    --with-kerberos-dir
    --without-kerberos-dir
    --with-kerberos-include
    --without-kerberos-include=${kerberos-dir}/include
    --with-kerberos-lib
    --without-kerberos-lib=${kerberos-dir}/lib
    --with-debug
    --without-debug
    --enable-debug
    --disable-debug
    --with-nsllib
    --without-nsllib
    --with-socketlib
    --without-socketlib
    --with-openssl-config
    --without-openssl-config
    --with-pkg-config
    --without-pkg-config
extconf.rb:99:in `<main>': OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed. (RuntimeError)

To see why this extension failed to compile,

  /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/openssl-2.2.0/mkmf.log

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/openssl-2.2.0 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/openssl-2.2.0/gem_make.out

Again, why does this happen? Please help!

1 Answer 1

3

openssl gem is basically a set of wrappers around openssl library. And bundler cannot find the library in your system during Building native extensions step. Thus the gem fails to install.

This is weird as the script you linked explicitly installs openssl long before bundling gems

log_info "Upgrading and linking OpenSSL ..."
  brew install openssl
  brew link openssl --force

Check the script's output for errors (and check if it has reached this step at all). You will probably find the reason for missing openssl library there (or simply try to install openssl manually more using the commands above).

After you install the openssl library check its version using command

openssl version -a

If you have a custom openssl library installation it might help to follow the advice from the error message and install openssl gem manually while specifying the path to openssl library

4
  • Do you know where is the path to the openSSL lib? Commented Feb 26, 2021 at 17:11
  • Wait so I keep getting "Invalid option --with-openssl-dir" Commented Feb 26, 2021 at 17:14
  • Ok I bypassed that openSSL error but now I have An error occurred while installing nokogumbo (2.0.4), and Bundler cannot continue. Make sure that `gem install nokogumbo -v '2.0.4' --source 'https://rubygems.org/'` succeeds before bundling. Commented Feb 26, 2021 at 17:43
  • And running any rake commands give me: Could not find openssl-2.2.0 in any of the sources Run `bundle install` to install missing gems. Commented Feb 26, 2021 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.