Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 16 additions & 9 deletions internal/devbox/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,22 @@ 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 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.
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` 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
! stderr 'nix flake update'

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