Skip to content

Preserve Windows paths in MAKE and rake environment variables#9693

Open
hsbt wants to merge 1 commit into
masterfrom
shellsplit-windows-make-path
Open

Preserve Windows paths in MAKE and rake environment variables#9693
hsbt wants to merge 1 commit into
masterfrom
shellsplit-windows-make-path

Conversation

@hsbt

@hsbt hsbt commented Jul 15, 2026

Copy link
Copy Markdown
Member

On Windows, setting MAKE (or make, or rake) to a native full path such as C:\Program Files (x86)\...\nmake.exe breaks extension builds. Gem::Ext::Builder splits the value with POSIX Shellwords, which consumes the backslashes as escape characters and splits on the spaces, so the command becomes C:Program, Files, (x86)Microsoft, ... and the build fails with No such file or directory. The only workaround is a bare executable name resolved through PATH.

This changes the splitting so that a value naming an existing file is taken as a single command word, falling back to Shellwords for anything else. Plain values like make -j4 and quoted paths keep working exactly as before, and non-Windows platforms are unaffected. The run helper now also spawns single-word commands with the [cmdname, argv0] form, because spawn parses a lone string as a shell command line and would split an unquoted path containing spaces again. The make invocation of the default build target is exactly this single-word case.

Verified on x64-mswin64_140: with MAKE set to the full nmake.exe path under C:\Program Files (x86), a real mkmf extension build failed with No such file or directory - C:Program before this change and succeeds after it.

POSIX Shellwords consumes backslashes, so MAKE=C:\path\nmake.exe was
split into "C:pathnmake.exe" and extension builds failed with make not
found. Take a value that names an existing file as a single word, and
spawn single-word commands with the [cmdname, argv0] form so a path
containing spaces is not parsed again as a shell command line.
Copilot AI review requested due to automatic review settings July 15, 2026 07:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants