ruby-build ignores pkg-config when deciding whether to install OpenSSL
If no compatible OpenSSL version is found, ruby-build downloads and installs OpenSSL.
When looking for a compatible OpenSSL version, ruby-build will try the system OpenSSL, then Homebrew-installed OpenSSL versions.
ruby-build should to be able to find an OpenSSL version installed by other package managers, using pkg-config (like Autoconf does when building Ruby).
Steps to reproduce the behavior
- Install Ruby dependencies, as well as pkg-config, using your package manager of choice (say MacPorts):
sudo port install pkgconfig openssl libyaml - Check that pkg-config is present and finds OpenSSL:
pkg-config --cflags --libs openssl - Check that OpenSSL version is 3.x.x:
pkg-config --modversion openssl - Check that Ruby builds correctly on your machine:
cd ruby-3.4.4 \ && ./autogen.sh \ && ./configure --prefix=/var/tmp/ruby-3.4.4 --enable-shared --with-ext=openssl,psych,+ \ && make install - Install Ruby using ruby-build:
ruby-build 3.4.4 /var/tmp/ruby-3.4.4
Expected behavior
ruby-build should use the OpenSSL package installed by the package manager.
Actual behavior
ruby-build downloads and builds OpenSSL.
Logs
==> Downloading openssl-3.0.16.tar.gz...
-> curl -q -fL -o openssl-3.0.16.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/57e03c50feab5d31b152af2b764f10379aecd8ee92f16c985983ce4a99f7ef86
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14.6M 100 14.6M 0 0 44.3M 0 --:--:-- --:--:-- --:--:-- 44.4M
==> Installing openssl-3.0.16...
-> ./config --prefix=/var/tmp/ruby-3.4.4/openssl --openssldir=/var/tmp/ruby-3.4.4/openssl/ssl --libdir=lib zlib-dynamic no-ssl3 shared
-> make -j 12
-> make install_sw install_ssldirs
==> Installed openssl-3.0.16 to /var/tmp/ruby-3.4.4
==> Downloading ruby-3.4.4.tar.gz...
-> curl -q -fL -o ruby-3.4.4.tar.gz https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.4.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 22.1M 100 22.1M 0 0 32.2M 0 --:--:-- --:--:-- --:--:-- 32.2M
==> Installing ruby-3.4.4...
-> ./configure --prefix=/var/tmp/ruby-3.4.4 --with-openssl-dir=/var/tmp/ruby-3.4.4/openssl --enable-shared --with-ext=openssl,psych,+
-> make -j 12
-> make install
==> Installed ruby-3.4.4 to /var/tmp/ruby-3.4.4
This also appears to apply to gmp which may be available via MacPorts.
Hi all, thanks for your contributions and the resulting discussion. Could you try the latest ruby-build master? This is how it should behave now:
- If a compatible openssl was found with pkg-config and does not come from Homebrew's cellar, ruby-build will skip downloading OpenSSL and compiling it, and it also won't try to link to Homebrew's openssl either.
- Auto-discovery of libraries such as readline (for Ruby < 3.3), libyaml, and gmp is just like before: if they are discovered from Homebrew, they will be auto-linked. I understand that people who prefer MacPorts (but also have Homebrew installed) would prefer them to be discovered via pkg-config rather than via
brew, and I'm open to improving the Homebrew opt-out process in the future.