Describe the bug
if pipx ensurepath is run on Windows, it breaks the path environment variable by changing the HKCU\Environment\Path value from a REG_EXPAND_SZ type to a REG_SZ type. This will cause all paths that contain environment variables within the path to not be expanded and therefore not searched.
How to reproduce
>reg query HKCU\Environment /v Path
HKEY_CURRENT_USER\Environment
Path REG_EXPAND_SZ C:\Users\su_heathes\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\su_heathes\AppData\Local\Programs\Python\Python38\;C:\Users\su_heathes\AppData\Local\Programs\Python\Launcher\;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Users\su_heathes\AppData\Roaming\npm
>pipx ensurepath
Success! Added C:\Users\su_heathes\.local\bin to the PATH environment variable.
Consider adding shell completions for pipx. Run 'pipx completions' for instructions.
You likely need to open a new terminal or re-login for the changes to take effect.
>reg query HKCU\Environment /v Path
HKEY_CURRENT_USER\Environment
Path REG_SZ C:\Users\su_heathes\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\su_heathes\AppData\Local\Programs\Python\Python38\;C:\Users\su_heathes\AppData\Local\Programs\Python\Launcher\;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Users\su_heathes\AppData\Roaming\npm;C:\Users\su_heathes\.local\bin
Expected behavior
Leave the HKCU\Environment\Path value as a REG_EXPAND_SZ type.
pipx version
0.15.4.0
Upstream issue with userpath. Ref: https://github.com/ofek/userpath/issues/27
Confirmed fixed upstream in userpath v1.4.1.
Thanks for the confirmation it's fixed.
pipx should require a version with the fix so it gets picked up in upgrades
https://github.com/pipxproject/pipx/blob/master/setup.py#L21
Most helpful comment
pipx should require a version with the fix so it gets picked up in upgrades
https://github.com/pipxproject/pipx/blob/master/setup.py#L21