Skip to content

fix(update): skip Nix calls when --no-install is set (#2585)#2913

Open
mikeland73 wants to merge 2 commits into
mainfrom
claude/focused-goldberg-3gnefs
Open

fix(update): skip Nix calls when --no-install is set (#2585)#2913
mikeland73 wants to merge 2 commits into
mainfrom
claude/focused-goldberg-3gnefs

Conversation

@mikeland73

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2585.

devbox update --no-install is documented as "update lockfile but don't install anything", but it still shelled out to Nix after refreshing the lockfile. In Devbox.Update two steps ran unconditionally, regardless of --no-install:

  • nix.FlakeUpdate(...) → runs nix flake update (this is the Info: Running "nix flake update" line the reporter sees).
  • d.FixMissingStorePaths(ctx) → runs nix path-info ....

ensureStateIsUpToDate(noInstall) already correctly avoids Nix (it skips installPackages and recomputeState), so these two trailing calls were the only thing still invoking Nix. Besides defeating the purpose of the flag, they break the command in environments where Nix isn't fully set up (e.g. CI/Renovate), where the reporter hit a hard crash:

Error: nix: command error: ... path-info 'github:NixOS/nixpkgs/...#python312Full' ...
  what():  error: cannot determine user's home directory

Changes

  • internal/devbox/update.go: guard the nix.FlakeUpdate and FixMissingStorePaths calls behind !opts.NoInstall so --no-install only refreshes the lockfile and never shells out to Nix. plugin.Update() (which just clears a cache and does not touch Nix) still runs.
  • testscripts/update/update.test.txt: add a regression assertion that devbox update --no-install does not print nix flake update.

How was it tested?

  • go build ./internal/devbox/ and go vet ./internal/devbox/ — clean.
  • gofmt -l internal/devbox/update.go — no diffs.
  • Added a testscript step (exec devbox update --no-install followed by ! stderr 'nix flake update') to the existing update testscript, which runs against real Nix in CI.

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.


cc @abeltavares (issue reporter)

🤖 Generated with Claude Code


Generated by Claude Code

`devbox update --no-install` still shelled out to Nix after refreshing the
lockfile: it unconditionally ran `nix flake update` (via FlakeUpdate) and
`nix path-info` (via FixMissingStorePaths). This defeats the purpose of
--no-install and breaks the command in environments where Nix isn't fully
set up (e.g. CI/Renovate), where those calls print "Running nix flake
update" or crash with "cannot determine user's home directory".

Guard both Nix-invoking steps behind `!opts.NoInstall` so the flag only
updates the lockfile. Add a regression testscript asserting that
`devbox update --no-install` does not run `nix flake update`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gtqrm1XgX3ZvcjHCJjuBgt
Copilot AI review requested due to automatic review settings July 10, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes devbox update --no-install still invoking Nix after refreshing the lockfile by skipping the trailing nix flake update and FixMissingStorePaths steps when --no-install is set, matching the documented behavior and preventing failures in environments where Nix isn’t fully configured (e.g. CI/Renovate).

Changes:

  • Guard nix.FlakeUpdate(...) and Devbox.FixMissingStorePaths(...) behind !opts.NoInstall in Devbox.Update.
  • Add a testscript regression assertion that devbox update --no-install does not emit nix flake update.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
internal/devbox/update.go Skips post-update Nix calls when --no-install is set.
testscripts/update/update.test.txt Adds regression coverage to ensure nix flake update is not invoked/logged under --no-install.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/devbox/update.go Outdated
Comment on lines +88 to +92
// With --no-install we only refresh the lockfile, so skip every step that
// shells out to Nix. This keeps `devbox update --no-install` usable in
// environments where Nix isn't fully set up (e.g. CI/Renovate), where
// running "nix flake update" or "nix path-info" would otherwise fail.
// See jetify-com/devbox#2585.
Comment thread testscripts/update/update.test.txt Outdated
Comment on lines +7 to +9
# `devbox update --no-install` only refreshes the lockfile and must not shell
# out to Nix (e.g. "nix flake update"). Regression test for #2585.
exec devbox update --no-install
Reword the code and testscript comments to describe exactly the two
post-update Nix steps that --no-install skips (nix flake update and
nix path-info), rather than implying the whole update flow avoids Nix.
Flake-ref resolution earlier in the flow may still invoke Nix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gtqrm1XgX3ZvcjHCJjuBgt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

devbox update --no-install still runs nix

3 participants