Skip to content

fix(shim): Windows shim incorrectly reports failure on non-zero exit code #59

@CalvinAllen

Description

@CalvinAllen

Description

On Windows, when a shimmed command (like npm) exits with a non-zero exit code, the dtvem shim incorrectly reports a failure error even though the command ran successfully.

Steps to Reproduce

  1. Run npm --version or npm config via the dtvem shim on Windows
  2. Observe the error message after the command output

Expected Behavior

The shim should silently propagate the exit code from the underlying command without printing an error message.

Actual Behavior

npm@10.5.1 C:\Users\user\.dtvem\versions\node\22.0.0\node_modules\npm
dtvem shim error: failed to execute C:\Users\user\.dtvem\versions\node\22.0.0\npm.cmd: exit status 1

Root Cause

On Windows, syscall.Exec is not supported, so the shim falls back to cmd.Run(). When the wrapped command exits with a non-zero code, cmd.Run() returns an *exec.ExitError, which the shim was treating as a failure rather than a normal exit with a specific code.

Solution

Detect *exec.ExitError and call os.Exit() with the command's exit code instead of returning an error.

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