fix: Added quotes to unquoted paths in python install and pip upgrade commands#378
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Windows Python toolcache setup PowerShell template to better handle hosted tool paths that contain spaces, specifically during pip bootstrapping/upgrade.
Changes:
- Quote
$PythonExePathwithin thecmd.exe /cinvocation forensurepipandpip install --upgradeto avoid failures when the Python path contains spaces.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hello all, simple change that likely affects a lot of consumers. Politely requesting a review from team? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $ExecParams = Get-ExecParams -IsMSI $IsMSI -IsFreeThreaded $IsFreeThreaded -PythonArchPath $PythonArchPath | ||
|
|
||
| cmd.exe /c "cd $PythonArchPath && call $PythonExecName $ExecParams /quiet" | ||
| cmd.exe /c "cd `"$PythonArchPath`" && call `"$PythonExecName`" $ExecParams /quiet" |
There was a problem hiding this comment.
Quoting $PythonArchPath and $PythonExecName fixes the cd/call parts, but $ExecParams still embeds $PythonArchPath unquoted (see Get-ExecParams). If $PythonArchPath contains spaces, the expanded command becomes ... TARGETDIR=C:\foo bar\... / DefaultAllUsersTargetDir=C:\foo bar\..., which cmd.exe/the installer will split into multiple arguments and can fail. Consider updating Get-ExecParams to quote the directory values (e.g., TARGETDIR="..." / DefaultAllUsersTargetDir="..."), or avoid cmd.exe and pass an argument array via Start-Process so quoting is handled correctly.
| cmd.exe /c "cd `"$PythonArchPath`" && call `"$PythonExecName`" $ExecParams /quiet" | |
| $InstallerPath = Join-Path -Path $PythonArchPath -ChildPath $PythonExecName | |
| & $InstallerPath @ExecParams '/quiet' |
Added backtick commented out quotes for python install and pip upgrade steps to avoid errors when the hosted tools path has a space in it.