feat(ruby): set PKG_CONFIG_PATH for native gem extensions#7457
Merged
Conversation
When the rubygems_plugin is loaded, prepend the Ruby installation's lib/pkgconfig directory to PKG_CONFIG_PATH. This allows gems with native extensions (openssl, psych, ffi, etc.) to find the bundled headers and libraries from precompiled Ruby binaries. Fixes: #7268 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds automatic PKG_CONFIG_PATH configuration for the rubygems plugin to support native gem extensions. When the plugin loads, it prepends Ruby's pkg-config directory to PKG_CONFIG_PATH, enabling gems with native extensions (openssl, psych, ffi) to locate bundled headers and libraries from precompiled Ruby binaries without manual environment setup.
Key changes:
- Adds PKG_CONFIG_PATH configuration at plugin initialization
- Uses RbConfig to locate Ruby's pkg-config directory
- Preserves existing PKG_CONFIG_PATH values
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.12 x -- echo |
20.5 ± 0.7 | 19.1 | 24.9 | 1.03 ± 0.04 |
mise x -- echo |
20.0 ± 0.4 | 19.2 | 22.2 | 1.00 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.12 env |
19.3 ± 0.7 | 18.6 | 25.7 | 1.00 |
mise env |
19.5 ± 0.3 | 18.8 | 21.3 | 1.01 ± 0.04 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.12 hook-env |
19.4 ± 0.3 | 18.8 | 20.4 | 1.00 |
mise hook-env |
19.8 ± 0.5 | 19.1 | 23.6 | 1.02 ± 0.03 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.12 ls |
17.1 ± 0.3 | 16.4 | 18.6 | 1.00 |
mise ls |
17.4 ± 0.9 | 16.5 | 26.0 | 1.01 ± 0.05 |
xtasks/test/perf
| Command | mise-2025.12.12 | mise | Variance |
|---|---|---|---|
| install (cached) | 110ms | 109ms | +0% |
| ls (cached) | 65ms | 66ms | -1% |
| bin-paths (cached) | 73ms | 72ms | +1% |
| task-ls (cached) | 2260ms | 2268ms | +0% |
Use File::PATH_SEPARATOR instead of hardcoded colon for PKG_CONFIG_PATH concatenation. This ensures correct behavior on Windows (which uses ;) in addition to Unix-like systems (which use :). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the rubygems_plugin is loaded, prepend the Ruby installation's
lib/pkgconfigdirectory toPKG_CONFIG_PATH. This allows gems with native extensions (openssl, psych, ffi, etc.) to find the bundled headers and libraries from precompiled Ruby binaries.Background
Precompiled Ruby binaries from jdx/ruby now include:
${pcfiledir}However, for
gem install opensslto work, pkg-config needs to find these.pcfiles. This PR setsPKG_CONFIG_PATHin the rubygems plugin so it's only active during gem operations.Related PR: jdx/ruby#1
Test plan
gem install openssl- should succeed without manual PKG_CONFIG_PATH setupgem install psych- should find libyaml headers🤖 Generated with Claude Code
Note
Prepends Ruby’s
lib/pkgconfigtoPKG_CONFIG_PATHin the rubygems plugin so native gem extensions can find bundled headers and libraries.lib/pkgconfigtoPKG_CONFIG_PATHinsrc/plugins/core/assets/rubygems_plugin.rb(when present) so native gem extensions can locate bundled headers/libs.Written by Cursor Bugbot for commit f0e9b93. This will update automatically on new commits. Configure here.