MCPcopy Index your code
hub / github.com/jetify-com/devbox / Remove

Method Remove

internal/devbox/packages.go:241–275  ·  view source on GitHub ↗

Remove removes the `pkgs` from the config (i.e. devbox.json) and nix profile for this devbox project

(ctx context.Context, pkgs ...string)

Source from the content-addressed store, hash-verified

239// Remove removes the `pkgs` from the config (i.e. devbox.json) and nix profile
240// for this devbox project
241func (d *Devbox) Remove(ctx context.Context, pkgs ...string) error {
242 ctx, task := trace.NewTask(ctx, "devboxRemove")
243 defer task.End()
244
245 packagesToUninstall := []string{}
246 missingPkgs := []string{}
247 for _, pkg := range lo.Uniq(pkgs) {
248 found, _ := d.findPackageByName(pkg)
249 if found != nil {
250 packagesToUninstall = append(packagesToUninstall, found.Raw)
251 d.cfg.PackageMutator().Remove(found.Raw)
252 } else {
253 missingPkgs = append(missingPkgs, pkg)
254 }
255 }
256
257 if len(missingPkgs) > 0 {
258 ux.Fwarningf(
259 d.stderr,
260 "the following packages were not found in your devbox.json: %s\n",
261 strings.Join(missingPkgs, ", "),
262 )
263 }
264
265 if err := plugin.Remove(d.projectDir, packagesToUninstall); err != nil {
266 return err
267 }
268
269 // this will clean up the now-extra package from nix profile and the lockfile
270 if err := d.ensureStateIsUpToDate(ctx, uninstall); err != nil {
271 return err
272 }
273
274 return d.saveCfg()
275}
276
277// installMode is an enum for helping with ensureStateIsUpToDate implementation
278type installMode string

Callers 5

AddMethod · 0.95
UpdateMethod · 0.95
GlobalDataPathFunction · 0.45
resetProfileDirForFlakesFunction · 0.45
wipeProfileHistoryFunction · 0.45

Calls 7

findPackageByNameMethod · 0.95
ensureStateIsUpToDateMethod · 0.95
saveCfgMethod · 0.95
FwarningfFunction · 0.92
RemoveFunction · 0.92
EndMethod · 0.80
PackageMutatorMethod · 0.80

Tested by

no test coverage detected