Skip to content

Commit 18daf6f

Browse files
CalvinAllenclaude
andcommitted
fix(shim): propagate exit code instead of reporting failure on windows
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 was incorrectly treated as a shim failure. Now the shim detects ExitError and calls os.Exit() with the command's actual exit code instead of printing a misleading error message. Fixes #59 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 92c5247 commit 18daf6f

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

CLAUDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Claude Code Instructions for dtvem
2+
3+
## Deployment
4+
5+
After building, always deploy both executables to the user's installation directory:
6+
7+
```bash
8+
cp dist/dtvem.exe ~/.dtvem/bin/dtvem.exe
9+
cp dist/shim.exe ~/.dtvem/bin/dtvem-shim.exe
10+
~/.dtvem/bin/dtvem.exe reshim
11+
```
12+
13+
The `reshim` command must be run after deploying the shim to regenerate all runtime shims (npm, node, python, etc.) with the updated binary.

src/cmd/shim/main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,17 @@ func executeCommand(execPath string, args []string) error {
311311
Stdout: os.Stdout,
312312
Stderr: os.Stderr,
313313
}
314-
return cmd.Run()
314+
if err := cmd.Run(); err != nil {
315+
// Check if this is an exit error (command ran but returned non-zero)
316+
var exitErr *exec.ExitError
317+
if errors.As(err, &exitErr) {
318+
// Command executed successfully but returned non-zero exit code
319+
// This is not a shim error - propagate the exit code
320+
os.Exit(exitErr.ExitCode())
321+
}
322+
// Other errors (couldn't start, etc.) are actual failures
323+
return err
324+
}
315325
}
316326

317327
return nil

0 commit comments

Comments
 (0)