diff --git a/internal/boxcli/update.go b/internal/boxcli/update.go index 009cb1b362d..eb2428092a0 100644 --- a/internal/boxcli/update.go +++ b/internal/boxcli/update.go @@ -17,6 +17,7 @@ type updateCmdFlags struct { config configFlags sync bool allProjects bool + noInstall bool } func updateCmd() *cobra.Command { @@ -49,6 +50,12 @@ func updateCmd() *cobra.Command { false, "update all projects in the working directory, recursively.", ) + command.Flags().BoolVar( + &flags.noInstall, + "no-install", + false, + "update lockfile but don't install anything", + ) return command } @@ -75,7 +82,8 @@ func updateCmdFunc(cmd *cobra.Command, args []string, flags *updateCmdFlags) err } return box.Update(cmd.Context(), devopt.UpdateOpts{ - Pkgs: args, + Pkgs: args, + NoInstall: flags.noInstall, }) } diff --git a/internal/devbox/devopt/devboxopts.go b/internal/devbox/devopt/devboxopts.go index 43f6224df53..b59759fe567 100644 --- a/internal/devbox/devopt/devboxopts.go +++ b/internal/devbox/devopt/devboxopts.go @@ -58,6 +58,7 @@ type AddOpts struct { type UpdateOpts struct { Pkgs []string + NoInstall bool IgnoreMissingPackages bool } diff --git a/internal/devbox/packages.go b/internal/devbox/packages.go index 2cdc9923e0b..88af2215dee 100644 --- a/internal/devbox/packages.go +++ b/internal/devbox/packages.go @@ -275,8 +275,9 @@ const ( install installMode = "install" uninstall installMode = "uninstall" // update is both install new package version and uninstall old package version - update installMode = "update" - ensure installMode = "ensure" + update installMode = "update" + ensure installMode = "ensure" + noInstall installMode = "noInstall" ) // ensureStateIsUpToDate ensures the Devbox project state is up to date. diff --git a/internal/devbox/update.go b/internal/devbox/update.go index 79b4693c3ab..4a06c8e2a9b 100644 --- a/internal/devbox/update.go +++ b/internal/devbox/update.go @@ -68,7 +68,11 @@ func (d *Devbox) Update(ctx context.Context, opts devopt.UpdateOpts) error { if err := d.updateStdenv(); err != nil { return err } - if err := d.ensureStateIsUpToDate(ctx, update); err != nil { + mode := update + if opts.NoInstall { + mode = noInstall + } + if err := d.ensureStateIsUpToDate(ctx, mode); err != nil { return err }