My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Pyenv, node-gyp, openssl on macOS

Heechul Ryu's photo
Heechul Ryu
·Mar 15, 2020

Today I experienced build failures on both $ pyenv install 3.7.7 and $ npm install -g @11ty/eleventy

Too bad I can't access actual output for build failures for both and can't seem to reproduce that easily anymore.

But I could reproduce $ pyenv doctor error at least and it looks like this.

❯ pyenv doctor
Cloning /Users/heechul/.pyenv/plugins/pyenv-doctor/bin/.....
Installing python-pyenv-doctor...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 10.15.3 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/sb/b0858z2x1s910lzb4ql6pt300000gn/T/python-build.20200315180457.83781
Results logged to /var/folders/sb/b0858z2x1s910lzb4ql6pt300000gn/T/python-build.20200315180457.83781.log

Last 10 log lines:
checking readline/readline.h, usability... no
checking readline/readline.h, presence... no
checking for readline/readline.h,... no
checking readline/rlconf.h usability... yes
checking readline/rlconf.h presence... yes
checking for readline/rlconf.h... yes
checking for SSL_library_init in -lssl... no
configure: WARNING: OpenSSL <1.1 not installed. Checking v1.1 or beyond...
checking for OPENSSL_init_ssl in -lssl... no
configure: error: OpenSSL is not installed.
Problem(s) detected while checking system.

See https://github.com/pyenv/pyenv/wiki/Common-build-problems for known solutions.

and node-gyp rebuild fail message was very similiar (or identical) to this

And weirdly I have openssl installed via brew

But I just gave another shot to reinstall $ brew uninstall openssl --ignore-depedencies && brew install openssl

And I found this message after reinstalling via homebrew.

❯ brew install openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.
Already downloaded: /Users/heechul/Library/Caches/Homebrew/downloads/427c5da28a48eaf91f7d64494c256860757d94dab5687068b5e5958ccbc20a2b--openssl@1.1-1.1.1d.catalina.bottle.tar.gz
==> Pouring openssl@1.1-1.1.1d.catalina.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

So I exported those ENV vars and ran $ pyenv doctor

❯ pyenv doctor
Cloning /Users/heechul/.pyenv/plugins/pyenv-doctor/bin/.....
Installing python-pyenv-doctor...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed python-pyenv-doctor to /var/folders/sb/b0858z2x1s910lzb4ql6pt300000gn/T/pyenv-doctor.20200315175655.66677/prefix

Yay! After that python build was successful too like below.

❯ pyenv install 3.7.7
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.7.tar.xz...
-> https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tar.xz
Installing Python-3.7.7...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.7.7 to /Users/heechul/.pyenv/versions/3.7.7

And node-gyp as well.

❯ npm install -g @11ty/eleventy
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/Users/heechul/.nvm/versions/node/v13.11.0/bin/eleventy -> /Users/heechul/.nvm/versions/node/v13.11.0/lib/node_modules/@11ty/eleventy/cmd.js

> fsevents@1.2.11 install /Users/heechul/.nvm/versions/node/v13.11.0/lib/node_modules/@11ty/eleventy/node_modules/fsevents
> node-gyp rebuild

  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
+ @11ty/eleventy@0.10.0
added 71 packages from 33 contributors and updated 1 package in 26.593s

Again too bad that I couldn't figure out what exactly was the root cause to this so that I can be confident what exactly is required to fix this. But hopefully this can be a hint for digging similar issues for anyone.