Skip to content

fix(init): use System PATH on Windows for correct priority #55

@CalvinAllen

Description

@CalvinAllen

Description

On Windows, the dtvem init command adds the shims directory to the User PATH. However, Windows combines PATH as System PATH + User PATH, meaning system installations (like C:\Program Files\nodejs) always take priority over dtvem shims.

This causes dtvem-managed versions to never be used when a system-level installation exists.

Root Cause

  • Windows PATH order: System PATH comes before User PATH
  • PowerShell 7 also prepends $PSHOME and reconstructs PATH with System before User
  • Adding to User PATH will never take priority over System PATH entries

Solution

  • Add shims to System PATH instead of User PATH
  • This requires administrator privileges
  • Prompt user for UAC elevation when needed
  • Re-launch dtvem init with elevation to make the change

Acceptance Criteria

  • dtvem init modifies System PATH on Windows (not User PATH)
  • Prompts for admin elevation if not already elevated
  • Uses ShellExecute with "runas" verb for UAC prompt
  • Works correctly when already elevated
  • Unix/macOS behavior unchanged (prepend to shell config)

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