-
Notifications
You must be signed in to change notification settings - Fork 602
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
[rush] Fix install-run-rush handling of spaces in paths #1003
Conversation
{ | ||
"comment": "Fix install-run-rush handling of spaces in paths", | ||
"packageName": "@microsoft/rush", | ||
"type": "none" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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] === '"' |
There was a problem hiding this comment.
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?
Hmm so this is why some programs/packages just say don’t use spaces...what a minefield...
I don’t actually know what problems using a shell might create (if any), which is why I did it only when necessary. Supposedly it’s a bit less efficient but I doubt that matters much here.
|
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.