Skip to content
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

Patch MakeMakefile for extension builds #13328

Merged
merged 2 commits into from
Jan 13, 2024

Conversation

chrisroberts
Copy link
Member

@chrisroberts chrisroberts commented Jan 12, 2024

As reported in #13322 Vagrant fails to install plugins with extensions
due to spaces in Windows paths causing errors. Further investigation
found that just quoting the paths used in the flags set by the Vagrant
launcher would not resolve the issue due to how gem authors may
be configuring the build. For example nokogiri appends environment flags
using String#split which improperly splits paths that include spaces
even if they are quoted.

To work around this, the MakeMakefile module needs to be patched to
properly quote any unquoted paths found within flags that may exist.
The module is required into extconf.rb files directly, however,
thus can't be patched directly. To work around this, the Gem.ruby
method is patched to include a custom load path. The custom load
path includes a mkmf.rb file that loads the real mkmf.rb file
and then proceeds to patch all the methods needed. Finally, all the
flags the Vagrant launcher defines in the environment are automatically
added.

This results in extension extconf.rb files using these patched methods
and preventing unexpected breakages when a space is included within
the path (which is always on Windows since the installation location
is within Program Files).

Full fix depends on package modifications included within hashicorp/vagrant-installers#289

Fixes #13322

Provides patches for MakeMakefile and modifies the Ruby path provided
when building extensions to allow loading the custom mkmf.rb file.

The patches perform inspection of flag values and quote any Windows
paths found that are not already quoted. This resolves issues where
builds fail due to spaces in compiler and linker flags on Windows.
@chrisroberts chrisroberts merged commit 8809fb6 into hashicorp:main Jan 13, 2024
11 checks passed
@chrisroberts chrisroberts deleted the windows-ext branch January 13, 2024 01:06
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing to install plugin on Windows with Vagrant 2.4.0
2 participants