Skip to content

Add support for pkg-config #2547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add support for pkg-config #2547

wants to merge 2 commits into from

Conversation

baarde
Copy link

@baarde baarde commented Jun 27, 2025

When pkg-config is installed and finds the libraries, use those rather than relying on Homebrew or bundling OpenSSL.

Fixes #2544


A few comments about package managers

  • I've tried hard not to break things for Homebrew. When the libraries and pkg-config have been installed using Homebrew, pkg-config finds the libraries in /opt/homebrew/Cellar/. However, those have their version number in the path, so I decided to ignore any library in */Cellar/* to avoid breaking Ruby when running brew upgrade.
  • When the libraries and pkg-config have been installed using different package managers, whoever comes first in the search path wins.
  • A package manager that distributes ruby-build should have pkg-config as a dependency as well as all required and optional libraries (openssl, readline, libffi, gmp) to make sure all the linked libraries come from the same source.

Alternatives considered

Skip --with-xyz-dir=

pkg-config is used internally by Ruby build scripts. So my initial idea was to skip the --with-xyz-dir= option when a library is discovered by pkg-config and let the build scripts do their job. However:

  • That doesn't work for gmp.
  • That may not work for other libraries with older Rubies.
  • Having the --with-xyz-dir= options appear in the output is helpful to make sure that the correct libraries are used.
  • "Explicit is better than implicit." 😉

Do nothing

My goal was to write a simple fix to have ruby-build work well with MacPorts (and other package managers). But doing so without breaking things turned out a little more complex than anticipated. Maybe it's just not worth it.

baarde added 2 commits June 27, 2025 10:09
When pkg-config is installed and finds the libraries, use those rather than relying on Homebrew or bundling OpenSSL.

Fixes rbenv#2544
Links to the Cellar break when packages are upgraded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ruby-build ignores pkg-config when deciding whether to install OpenSSL
1 participant