Skip to content

Instantly share code, notes, and snippets.

@sneal
Last active February 10, 2022 15:25
Show Gist options
  • Save sneal/1ef97bb74f4fdb50ebf6a40ee67b20b1 to your computer and use it in GitHub Desktop.
Save sneal/1ef97bb74f4fdb50ebf6a40ee67b20b1 to your computer and use it in GitHub Desktop.
vSphere CPI - Fix Ruby Compilation on Mac

There are other ways to address this with prefix paths etc. however I'm compiling Ruby via bosh create-env and there is limited flexibility since the packaging script for the CPI dictates all of this.

Given that the vSphere CPI currently requires Ruby 2.6.5 which requires OpenSSL 1.x, the best option on Mac is brew install OpenSSL 1.1.latest as the LibreSSL version that ships with Mac doesn't have the proper headers to compile Ruby. These instructions install OpenSSL via Homebrew then symlink it to the locations that the CPI packaging script expects.

The final step is to copy the OpenSSL packaging configs to the location expected otherwise Ruby compiles fine but doesn't properly include OpenSSL so when you try to install Ruby Gems it fails with a LoadError. These could probably be symlinked instead of copied.

I also had a few env vars set which I'm fairly certain aren't used, but just in case:

export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
#!/usr/bin/env bash
brew install openssl@1.1
mkdir -p /usr/local/opt/openssl/lib/
ln -s /usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib /usr/local/opt/openssl/lib/
ln -s /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib /usr/local/opt/openssl/lib/
pushd /usr/local/opt/openssl/lib/
ln -s libssl.1.1.dylib libssl.dylib
ln -s libcrypto.1.1.dylib libcrypto.dylib
popd
cp /usr/local/opt/openssl@1.1/lib/pkgconfig/*.pc /usr/local/lib/pkgconfig/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment