Skip to content

[rush] Fix install-run-rush handling of spaces in paths#1003

Closed
ecraig12345 wants to merge 1 commit into
microsoft:masterfrom
ecraig12345:path-spaces
Closed

[rush] Fix install-run-rush handling of spaces in paths#1003
ecraig12345 wants to merge 1 commit into
microsoft:masterfrom
ecraig12345:path-spaces

Conversation

@ecraig12345

@ecraig12345 ecraig12345 commented Dec 20, 2018

Copy link
Copy Markdown
Member

On Windows, if the user puts their Git repo in a path with spaces (as in microsoft/fluentui#7508) and tries to use the install-run-rush.js script, it will fail. For whatever reason, paths with spaces work fine on Macs.

Fix is to wrap the path in quotes if it contains any spaces, then spawn the child process in a shell so the quotes are interpreted properly (as suggested by nodejs/node#7367 (comment)). My current implementation only uses quotes and a shell when necessary, but it could be changed to always do so.

{
"comment": "Fix install-run-rush handling of spaces in paths",
"packageName": "@microsoft/rush",
"type": "none"

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.

Shouldn't this be patch?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was automatically set to none, I'm guessing because there's already a patch update pending (Rush isn't published automatically)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rush uses lockstep versioning, so the version bump is determined by the config file that governs the next release, not by the person running rush change. I agree that "type": "none" doesn't convey this very clearly.

const binFolderPath: string = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin');
const resolvedBinName: string = (os.platform() === 'win32') ? `${binName}.cmd` : binName;
return path.resolve(binFolderPath, resolvedBinName);
const resolvedBinName: string = isWindows ? `${binName}.cmd` : binName;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

getBinPath() is supposed to return a path. A path should not contain shell escaping. The quotation marks you are adding here are an encoding detail of a particular shell, so this isn't a good place to apply that logic.

env: process.env,
// If binPath contains spaces, it must be quoted, and quoted paths will only be processed
// correctly if we use a shell (otherwise don't use a shell since it's a bit less efficient).
shell: binPath[0] === '"'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not sure there is an easy general solution here. See these notes for some background.

But what happens if we simply set shell: true in all cases? Or always when the OS is Windows? Would that improve the situation you encountered without breaking other scenarios?

@ecraig12345

ecraig12345 commented Dec 21, 2018 via email

Copy link
Copy Markdown
Member Author

@octogonz octogonz changed the title Fix install-run-rush handling of spaces in paths [rush] Fix install-run-rush handling of spaces in paths Feb 17, 2019
@halfnibble halfnibble self-assigned this Jun 21, 2019
@ecraig12345 ecraig12345 closed this Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants