From time to time you run into an issue that requires no end of Googling to sort through. That was my case with using bundler and the OpenSSL gem on macOS Big Sur. Your
Gemfile has the following contents:
and when running
bundle install you’re greeted with this nonsense:
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) ... An error occurred while installing openssl (2.2.0), and Bundler cannot continue.
gem install “only” required the following incantation:
gem install openssl --install-dir vendor/bundle -- --with-openssl-dir=/usr/local/Cellaremail@example.com/1.1.1h
For the life of me, though, I couldn’t figure out how to apply the
Well, dear reader, here is how:
bundle config path vendor/bundle bundle config build.openssl --with-openssl-dir=/usr/local/Cellarfirstname.lastname@example.org/1.1.1h
The first line is obligatory and is the “modern” way of setting
bundle‘s install path to
vendor/bundle (which odds are you want anyway). The
build.openssl setting will use the remaining information to pass to
gem when installing
It goes without saying that the exact path used is dependent on your environment; for my Mac the OpenSSL headers and libraries were hanging out in the brew cellar.
Hopefully this post saves someone an hour or so!