Problems installing Puma after upgrading Ruby

08 Dec 2023

I just updated Ruby in FormBackend to 3.1.2 and when I ran bundle install afterwards I ran into the following error:

3 warnings generated.
compiling puma_http11.c
linking shared-object puma/puma_http11.bundle
ld: warning: -multiply_defined is obsolete
ld: Undefined symbols:
  _SSL_get1_peer_certificate, referenced from:
      _engine_peercert in mini_ssl.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [puma_http11.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/jespr/.gem/ruby/3.1.2/gems/puma-5.6.4 for inspection.

After some Googling around, it appeared it was because there was some issues finding my local OpenSSL installation (which is managed by Homebrew). Turned out the solution was to run this:

bundle config --local build.puma --with-opt-dir=$(brew --prefix openssl)

and then run bundle install again!