Skip to content

bug: Pathman rewrites user env path value type as REG_SZ #10

@chipbite

Description

@chipbite

Describe the bug

Running sample cmd:

%userprofile%\bin\pathman.exe add ~/bin

Expected: %userprofile%\bin (or perhaps expanded, e g C:\Users\JohnDoe\bin ) added to REG_EXPAND_SZ Path value of HKCU\Environment key.

Actual: Path entry is added as expected (well, almost), but value is rewritten as REG_SZ type.

To Reproduce

  1. In fresh win11, check registry.
    Example:

Image of user env path in registry, first hit from random site on internet

Notice type of PATH value.

  1. In cmd.exe, run sample cmd (%userprofile%\bin\pathman.exe add ~/bin). Check registry again.

I get:

Image

or

C:\Users\mawid6>reg query "HKCU\Environment"

HKEY_CURRENT_USER\Environment
    Path    REG_SZ    C:\Users\mawid6/bin;C:\Users\mawid6\AppData\Local\Programs\Python\Python313\Scripts\;C:\Users\mawid6\AppData\Local\Programs\Python\Python313\;C:\Users\mawid6\AppData\Local\Programs\Python\Launcher\;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Users\mawid6\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\mawid6\AppData\Local\Microsoft\WinGet\Links;C:\Users\mawid6\AppData\Roaming\npm;%USERPROFILE%\go\bin
    TEMP    REG_EXPAND_SZ    %USERPROFILE%\AppData\Local\Temp

Device / Machine (please complete):

  • OS/Device: Win 11, Microsoft Windows [Version 10.0.26100.3775]

Image

  • Arch: x64 (installed amd64 version, e g https://git.rootprojects.org/root/pathman/releases/download/v0.5.2/pathman-v0.5.2-windows-amd64.zip).
  • Version 0.5.2.

Additional context / Impact

I doubt this has any actual impact on anything, TBH, but it just looks rather "clueless" and I immediately reacted with a feeling of unease, like "if this passes, how can I trust this command?". And I think it should be easy to fix, have not checked the code.

git-bash startup broke for me, since my user env path has a few %USERPROFILE%\bin like entries. When I manually changed the valuetype back to REG_EXPAND_SZ, it worked fine again - so it seems that was the culprit. It seems likely that it parses the regedit values based, and based on the type - if it is REG_EXPAND_SZ - it does variable expansion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions