Skip to content

Commit

Permalink
Merge pull request #2627 from manrueda/fix/windows-support-install-sc…
Browse files Browse the repository at this point in the history
…ripts

[rush-lib] Fix issue on Windows with paths that contains spaces
  • Loading branch information
iclanton authored Apr 26, 2021
2 parents b181eb3 + 7aaa820 commit 4aa649c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/rush-lib/src/scripts/install-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,16 @@ export function installAndRun(
const originalEnvPath: string = process.env.PATH || '';
let result: childProcess.SpawnSyncReturns<Buffer>;
try {
// Node.js on Windows can not spawn a file when the path has a space on it
// unless the path gets wrapped in a cmd friendly way and shell mode is used
const shouldUseShell: boolean = binPath.includes(' ') && os.platform() === 'win32';
const platformBinPath: string = shouldUseShell ? `"${binPath}"` : binPath;

process.env.PATH = [binFolderPath, originalEnvPath].join(path.delimiter);
result = childProcess.spawnSync(binPath, packageBinArgs, {
result = childProcess.spawnSync(platformBinPath, packageBinArgs, {
stdio: 'inherit',
windowsVerbatimArguments: false,
shell: shouldUseShell,
cwd: process.cwd(),
env: process.env
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Fix an issue where Rush fails to run on Windows when the repository absolute path contains a space",
"type": "none"
}
],
"packageName": "@microsoft/rush",
"email": "manrueda@users.noreply.github.com"
}

0 comments on commit 4aa649c

Please sign in to comment.