You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1d9ea45
Browse filesBrowse the repository at this point in the historyBrowse files
feat(config): add "auto" devbox_version policy to switch versions (#2991)
## Summary
Stacked on #2990, which adds `devbox_version`. Merge that first.
Adds an `auto` policy that switches to the pinned devbox version:
```json
"devbox_version": {"version": "0.18.4", "on_mismatch": "auto"}
```
- **How switching works:** when the running devbox doesn't match, it
re-runs the same command through the devbox launcher (`$LAUNCHER_PATH`)
with `DEVBOX_USE_VERSION` set to the pinned version.
- The existing launcher already downloads, checksum-verifies and runs
any release named by `DEVBOX_USE_VERSION`, so the launcher needs no
changes.
- Download progress goes to stderr, so `shellenv` and direnv output
stays clean.
- **Exact versions only:** `auto` requires an exact version; a range
with `auto` is a config error. `DEVBOX_VERSION_POLICY=auto` with a range
fails like `error`.
- **A `DEVBOX_USE_VERSION` set by the user wins:** devbox warns instead
of switching.
- **Loop guard:** `__DEVBOX_AUTO_VERSION` marks a version that `auto`
chose. That lets a nested shell switch again for a different project,
and makes devbox fail instead of looping if the launcher doesn't switch.
- **Without a launcher** (for example Nix or Homebrew installs), `auto`
fails with install instructions.
- **Inheritance:** `DEVBOX_USE_VERSION` carries into `devbox shell`, so
nested devbox commands stay on the pinned version.
## How was it tested?
- Unit tests with a mocked `exec` cover: switching, replacing existing
env values, switching again for a different project, no launcher, the
loop guard, a user-set version winning, and the env override with a
range.
- `testscripts/version/devbox_version_auto.test.txt` uses a fake
launcher script to check that the same command is re-run with
`DEVBOX_USE_VERSION` set. It also covers the no-launcher error, a
user-set version winning, and rejecting ranges.
- Manual end-to-end run with the real launcher (v0.2.2): a binary built
as 0.17.1, run in a project pinned to `0.18.4` with `auto`, ran `devbox
run` under 0.18.4. Inside the script, `devbox version` printed 0.18.4
and `DEVBOX_USE_VERSION=0.18.4`.
- `go test ./internal/...` and `devbox run lint` pass.
## 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).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .schema/devbox.schema.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -33,8 +33,8 @@
33
33
},
34
34
"on_mismatch": {
35
35
"type": "string",
36
-
"description": "What to do when the running devbox version doesn't satisfy the constraint. \"warn\" prints a warning (default) and \"error\" fails the command.",
37
-
"enum": ["warn", "error"]
36
+
"description": "What to do when the running devbox version doesn't satisfy the constraint. \"warn\" prints a warning (default), \"error\" fails the command, and \"auto\" re-runs the command with the required version (requires an exact version).",
0 commit comments