Commit 1dae9ff
boxcli: fix VS Code binary path resolution on macOS (#2806)
## Summary
The WSL fix in #2729 (4ba6fce) broke "Reopen in Devbox shell
environment" on macOS.
That commit constructs the VS Code binary path as
`$VSCODE_CWD/bin/code`. On WSL, `VSCODE_CWD` points to the VS Code
installation directory (e.g., `/mnt/c/.../Microsoft VS Code`), so this
works correctly. On macOS however, `VSCODE_CWD` is set to the workspace
directory, producing a path like `/Users/user/my-project/bin/code` —
which doesn't exist:
e.g. The debug logs on my machine gives:
```
fork/exec /Users/josh/src/my-project/bin/code: no such file or directory
```
This PR adds an os.Stat check so the constructed path is only used when
the binary actually exists there, falling back to the bare command name
(resolved via `PATH`) otherwise. The resolution logic is extracted into
a `resolveEditorBinary` function with unit tests covering:
- `VSCODE_CWD` unset → uses bare name
- `VSCODE_CWD` points to a VS Code installation (WSL) → uses full path
- `VSCODE_CWD` points to a workspace directory (macOS) → falls back to
bare name
## How was it tested?
- Unit tests for `resolveEditorBinary` covering all three scenarios
- `go test -race -cover ./internal/boxcli/` passes
- `golangci-lint run ./internal/boxcli/` passes
## Community Contribution License
All community contributions in this pull request are licensed to the
project
maintainers under the terms of the
[Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0).
By creating this pull request, I represent that I have the right to
license the
contributions to the project maintainers under the Apache 2 License as
stated in
the
[Community Contribution
License](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license).
Co-authored-by: Josh Godsiff <josh.godsiff@corro.co>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 8e36761 commit 1dae9ff
2 files changed
+95
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 127 | + | |
133 | 128 | | |
134 | 129 | | |
135 | 130 | | |
| |||
145 | 140 | | |
146 | 141 | | |
147 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
148 | 160 | | |
149 | 161 | | |
150 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments