Pipx: Pipx ensurepath Breaks the Path Environment on Windows

Created on 25 Jun 2020  路  5Comments  路  Source: pipxproject/pipx

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

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

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings