Preserve Windows paths in MAKE and rake environment variables#9693
Open
hsbt wants to merge 1 commit into
Open
Conversation
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.
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.
On Windows, setting
MAKE(ormake, orrake) to a native full path such asC:\Program Files (x86)\...\nmake.exebreaks extension builds.Gem::Ext::Buildersplits the value with POSIXShellwords, which consumes the backslashes as escape characters and splits on the spaces, so the command becomesC:Program,Files,(x86)Microsoft, ... and the build fails withNo such file or directory. The only workaround is a bare executable name resolved throughPATH.This changes the splitting so that a value naming an existing file is taken as a single command word, falling back to
Shellwordsfor anything else. Plain values likemake -j4and quoted paths keep working exactly as before, and non-Windows platforms are unaffected. Therunhelper now also spawns single-word commands with the[cmdname, argv0]form, becausespawnparses a lone string as a shell command line and would split an unquoted path containing spaces again. Themakeinvocation of the default build target is exactly this single-word case.Verified on
x64-mswin64_140: withMAKEset to the fullnmake.exepath underC:\Program Files (x86), a realmkmfextension build failed withNo such file or directory - C:Programbefore this change and succeeds after it.