Repository navigation
Run the vcpkg pkgconf and load vcpkg DLLs on mswin - #978
Merged
Merged
Conversation
mkmf skips an absolute PKG_CONFIG that File.expand_path would rewrite, so the backslashed path never ran pkgconf and extensions built only through their header and library fallbacks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mswin Ruby ships z.dll, not the libz.dll that vcpkg's libz.lib imports, so a zlib extension built against vcpkg failed to load and then broke RubyGems in that gem home. The other vcpkg DLLs still resolve to the copies in Ruby's own bin first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Building fiddle succeeded even while a zlib extension linked to libz.dll could not be loaded. The step activates the installed zlib explicitly, because Ruby also ships a default zlib built against its own z.dll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ntkme
approved these changes
Nov 18, 2026
ntkme
reviewed
Nov 18, 2026
| // Otherwise mkmf runs the MSYS2 pkg-config, whose MinGW flags break MSVC builds. mkmf accepts an absolute PKG_CONFIG only with forward slashes, and pkgconf alone searches just the missing tools\lib\pkgconfig | ||
| exportEnv({ | ||
| PKG_CONFIG: `${vcpkgDir}\\tools\\pkgconf\\pkgconf.exe`, | ||
| PKG_CONFIG: `${vcpkgDir}\\tools\\pkgconf\\pkgconf.exe`.replaceAll('\\', '/'), |
Collaborator
There was a problem hiding this comment.
Should mkmf support either forward slash or backward slash?
Member
Author
There was a problem hiding this comment.
Yes, it should. I'm working on making native builds on mswin work properly, and I'll use this case, where mkmf silently ignores a backslashed absolute PKG_CONFIG, as material to improve mkmf there.
Member
Author
There was a problem hiding this comment.
This is fixed in ruby/ruby#19970, so mkmf now accepts a backslashed absolute PKG_CONFIG on master. Released versions still need the forward slashes here.
hsbt
added a commit
to ruby/ruby
that referenced
this pull request
Nov 18, 2026
`find_executable0` treated a path as absolute only when `File.expand_path` returned it unchanged, so a Windows path written with backslashes, such as a `PKG_CONFIG` pointing at vcpkg's pkgconf, was looked up in `PATH` and never found. Use `File.absolute_path?` instead, which also accepts absolute paths containing `..` or `.` on every platform. ruby/setup-ruby#978 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
After #977, mkmf on mswin still never runs the vcpkg pkgconf. It skips an absolute
PKG_CONFIGthatFile.expand_pathwould rewrite, and setup-ruby writes it with backslashes, so extensions build only through theirhave_headerfallbacks. A zlib extension built against vcpkg also linkslibz.dll, which the Ruby package does not ship, sorequire "zlib"fails withLoadErrorand breaks RubyGems in that gem home.This writes
PKG_CONFIGwith forward slashes and appends the vcpkgbintoPATH. Ruby's ownbinstill comes first, so the other DLLs keep resolving to the copies shipped with Ruby.Generated with Claude Code