Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions internal/devbox/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,24 @@ func (d *Devbox) Update(ctx context.Context, opts devopt.UpdateOpts) error {
return err
}

// I'm not entirely sure this is even needed, so ignoring the error.
// It's definitely not needed for non-flakes. (which is 99.9% of packages)
// It will return an error if .devbox/gen/flake is missing
// TODO: Remove this if it's not needed.
_ = nix.FlakeUpdate(shellgen.FlakePath(d))

// fix any missing store paths.
if err = d.FixMissingStorePaths(ctx); err != nil {
return errors.WithStack(err)
// With --no-install, skip the two post-update steps that shell out to Nix:
// "nix flake update" (via FlakeUpdate) and "nix path-info" (via
// FixMissingStorePaths). This keeps `devbox update --no-install` usable in
// environments where Nix isn't fully set up (e.g. CI/Renovate), where those
// calls would otherwise fail. Earlier steps in the update flow may still
// resolve flake refs via Nix; --no-install only avoids these install-like
// steps. See jetify-com/devbox#2585.
if !opts.NoInstall {
// I'm not entirely sure this is even needed, so ignoring the error.
// It's definitely not needed for non-flakes. (which is 99.9% of packages)
// It will return an error if .devbox/gen/flake is missing
// TODO: Remove this if it's not needed.
_ = nix.FlakeUpdate(shellgen.FlakePath(d))

// fix any missing store paths.
if err = d.FixMissingStorePaths(ctx); err != nil {
return errors.WithStack(err)
}
}

return plugin.Update()
Expand Down
5 changes: 5 additions & 0 deletions testscripts/update/update.test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ exec devbox install

exec devbox update

# `devbox update --no-install` must not run the post-update "nix flake update"
# step. Regression test for #2585.
exec devbox update --no-install
! stderr 'nix flake update'

-- devbox.json --
{
"packages": [
Expand Down
Loading