Skip to content

fix: clear build-time pkg-config path from rbconfig - #55

Merged
jdx merged 2 commits into
mainfrom
codex/fix-pkg-config-rbconfig
Jul 13, 2026
Merged

fix: clear build-time pkg-config path from rbconfig#55
jdx merged 2 commits into
mainfrom
codex/fix-pkg-config-rbconfig

Conversation

@jdx

@jdx jdx commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • clear the build-time PKG_CONFIG value from both portable RbConfig hashes
  • allow mkmf to honor ENV["PKG_CONFIG"] or discover pkg-config on PATH

Root cause

The Ruby build records the bootstrap pkgconf executable's absolute path in rbconfig.rb. That path points inside the GitHub Actions build tree and does not exist after the Ruby archive is installed elsewhere. Since mkmf prefers the configured value, the stale path also prevents its environment and PATH fallbacks from running.

The existing portability patch already updates both RbConfig::CONFIG and RbConfig::MAKEFILE_CONFIG; clearing PKG_CONFIG there restores mkmf's normal fallback behavior for native gems such as ruby-magic.

Fixes the packaging problem reported in jdx/mise discussion #10913.

Validation

  • git diff --check
  • ruby -c libexec/package.rb
  • bin/validate-recipes

The PR build workflow will additionally build and exercise a portable Ruby artifact.


Note

Low Risk
Single-line change in the existing rbconfig portability patch; affects only shipped RbConfig for native gem builds, not the Ruby compile itself.

Overview
Portable Ruby installs were baking the CI/bootstrap pkgconf absolute path into RbConfig, so mkmf kept calling a binary that no longer exists after the tarball is unpacked elsewhere and never fell back to ENV["PKG_CONFIG"] or pkg-config on PATH.

The rbconfig_portability_patch now deletes PKG_CONFIG from both RbConfig::CONFIG and RbConfig::MAKEFILE_CONFIG, alongside the existing scrub of build-tree compiler flags. Native extension builds (e.g. ruby-magic) can discover pkg-config normally at install time.

Reviewed by Cursor Bugbot for commit bf60044. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Improved pkg-config discovery during builds by honoring the configured environment or system PATH instead of relying on a fixed value.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The embedded Ruby RbConfig portability patch now clears CONFIG["PKG_CONFIG"], allowing mkmf to use ENV["PKG_CONFIG"] or locate pkg-config through PATH.

Changes

PKG_CONFIG portability

Layer / File(s) Summary
Clear embedded PKG_CONFIG configuration
libexec/package.rb
The RbConfig patch sets CONFIG["PKG_CONFIG"] to an empty string and documents environment or PATH-based discovery.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

I’m a bunny with a build-time tune,
Clearing hardcoded paths beneath the moon.
Let the environment choose the way,
Or find pkg-config in PATH today.
Hop, compile, and bloom!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: clearing the build-time pkg-config path from RbConfig.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdx
jdx marked this pull request as ready for review July 12, 2026 00:19
@greptile-apps

greptile-apps Bot commented Jul 12, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes portable Ruby artifacts baking the CI-time pkgconf absolute path into RbConfig, which caused mkmf to call a non-existent binary when users built native gems after installation. The fix is a single config.delete("PKG_CONFIG") call inside the existing rbconfig_portability_patch, which already iterates over both RbConfig::CONFIG and RbConfig::MAKEFILE_CONFIG.

  • Deletes PKG_CONFIG from both RbConfig::CONFIG and MAKEFILE_CONFIG during packaging, restoring mkmf's normal ENV["PKG_CONFIG"] / PATH fallback when building native extensions.
  • Consistent approach: AR, NM, and RANLIB are set to bare tool names (relying on PATH); deleting PKG_CONFIG entirely is correct here because setting it to "" would be truthy and break mkmf's || fallback chains — the previous comment on this PR flagged exactly that risk.

Confidence Score: 5/5

Single-line change with no runtime behavior impact outside of native gem builds on portable Ruby installs; the deleted key is replaced by normal mkmf discovery.

The change is one config.delete call inside an existing loop that already scrubs both RbConfig::CONFIG and RbConfig::MAKEFILE_CONFIG. Deleting the key is unambiguous and correct — it cannot silently break anything that setting it to empty string would have broken. PKG_CONFIG_PATH is still properly set on line 602, so the portable lib path remains available to whatever pkg-config binary mkmf resolves.

No files require special attention.

Important Files Changed

Filename Overview
libexec/package.rb Adds config.delete("PKG_CONFIG") inside rbconfig_portability_patch's CONFIG/MAKEFILE_CONFIG loop; cleanly removes the stale build-time pkgconf path from both hashes so mkmf falls back to ENV["PKG_CONFIG"] or PATH discovery.

Reviews (2): Last reviewed commit: "fix: remove pkg-config from portable rbc..." | Re-trigger Greptile

Comment thread libexec/package.rb Outdated
@jdx
jdx merged commit 3739b9d into main Jul 13, 2026
11 checks passed
@jdx
jdx deleted the codex/fix-pkg-config-rbconfig branch July 13, 2026 18:39
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.

1 participant