feat(config): add "auto" devbox_version policy to switch versions - #2991
Merged
Merged
Conversation
Collaborator
Author
|
@claude ptal |
|
Claude finished @mikeland73's task in 2m 14s —— View job Reviewing PR #2991
ReviewI read through Correctness checks I traced through and confirm are right:
Minor observations (non-blocking):
No changes requested — this looks ready to merge from a correctness standpoint. |
mikeland73
added this pull request to stack #2992
September 28, 2026 18:00
mikeland73
force-pushed
the
mikeland73/devbox-version-auto
branch
from
September 28, 2026 18:24
695ae2e to
83567de
Compare
Add a top-level `devbox_version` field to devbox.json that declares which devbox versions a project supports (#1371). It accepts a semver constraint string, or an object with an explicit mismatch policy: "devbox_version": "^0.18.0" "devbox_version": {"version": "0.18.4", "on_mismatch": "error"} When the running devbox doesn't satisfy the constraint, "warn" (the default) prints a warning once per project per process tree and "error" fails the command. DEVBOX_VERSION_POLICY=off|warn|error overrides the policy. The check runs in devbox.Open right after the config loads, before the lockfile is read, so it covers every command that opens a project (including `devbox global`). Development builds skip it. Constraints use npm-style syntax via Masterminds/semver, which moves from an indirect to a direct dependency. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
For range constraints, the mismatch message always suggested `devbox version update`, but that only moves to the latest release. If the running version is already past the constraint's upper bound, or the latest release doesn't satisfy it, updating can't fix the mismatch. Now we only suggest it when the latest version (DEVBOX_LATEST_VERSION) satisfies the constraint, and otherwise point at DEVBOX_USE_VERSION alone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ntally Two places opened the current directory's project on every devbox invocation, so the devbox_version check fired for commands that don't use the project (e.g. `devbox version` printed the mismatch warning), and a swallowed error let `devbox run --list` ignore the "error" policy: - `devbox run` computed ValidArgs eagerly while building the command tree. It's now a lazy ValidArgsFunction that only runs during shell completion, which also lets cobra parse --config for us. listScripts now returns its error, so `run --list` and bare `run` report it. - The telemetry middleware opens the project after every command to record package names. Add devopt.Opts.SkipVersionCheck for these incidental opens (telemetry and completion), and cover `devbox version` and `run --list` in the testscript. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
With `"devbox_version": {"version": "0.18.4", "on_mismatch": "auto"}`, a
devbox that doesn't match re-runs the same command through the devbox
launcher with DEVBOX_USE_VERSION set to the required version. The launcher
already downloads and runs any release named by DEVBOX_USE_VERSION, so no
launcher change is needed.
- "auto" requires an exact version; a range with "auto" is a config error.
- A DEVBOX_USE_VERSION set by the user wins; devbox warns instead of
switching. __DEVBOX_AUTO_VERSION tells the two apart and stops re-exec
loops if the launcher doesn't switch.
- Without a launcher (e.g. Nix or Homebrew installs), "auto" fails with
instructions, like "error".
- DEVBOX_VERSION_POLICY also accepts "auto".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mikeland73
force-pushed
the
mikeland73/devbox-version-auto
branch
from
September 28, 2026 19:00
83567de to
901a835
Compare
Base automatically changed from
mikeland73/devbox-version-constraint
to
main
September 28, 2026 22:23
…sion-auto main has the squash-merged devbox_version change (#2990). Conflicts in the devbox_version files are add/add conflicts where this branch's version is main's plus the "auto" policy, so this branch's side is kept. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #2990, which adds
devbox_version. Merge that first.Adds an
autopolicy that switches to the pinned devbox version:$LAUNCHER_PATH) withDEVBOX_USE_VERSIONset to the pinned version.DEVBOX_USE_VERSION, so the launcher needs no changes.shellenvand direnv output stays clean.autorequires an exact version; a range withautois a config error.DEVBOX_VERSION_POLICY=autowith a range fails likeerror.DEVBOX_USE_VERSIONset by the user wins: devbox warns instead of switching.__DEVBOX_AUTO_VERSIONmarks a version thatautochose. That lets a nested shell switch again for a different project, and makes devbox fail instead of looping if the launcher doesn't switch.autofails with install instructions.DEVBOX_USE_VERSIONcarries intodevbox shell, so nested devbox commands stay on the pinned version.How was it tested?
execcover: 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.txtuses a fake launcher script to check that the same command is re-run withDEVBOX_USE_VERSIONset. It also covers the no-launcher error, a user-set version winning, and rejecting ranges.0.18.4withauto, randevbox rununder 0.18.4. Inside the script,devbox versionprinted 0.18.4 andDEVBOX_USE_VERSION=0.18.4.go test ./internal/...anddevbox run lintpass.Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
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.
🤖 Generated with Claude Code