MCPcopy Create free account
hub / github.com/jetify-com/devbox / resetProfileDirForFlakes

Function resetProfileDirForFlakes

internal/devbox/packages.go:435–463  ·  view source on GitHub ↗

resetProfileDirForFlakes ensures the profileDir directory is cleared of old state if the Flakes feature has been changed, from the previous execution of a devbox command.

(profileDir string)

Source from the content-addressed store, hash-verified

433// resetProfileDirForFlakes ensures the profileDir directory is cleared of old
434// state if the Flakes feature has been changed, from the previous execution of a devbox command.
435func resetProfileDirForFlakes(profileDir string) (err error) {
436 if resetCheckDone {
437 return nil
438 }
439 defer func() {
440 if err == nil {
441 resetCheckDone = true
442 }
443 }()
444
445 dir, err := filepath.EvalSymlinks(profileDir)
446 if errors.Is(err, fs.ErrNotExist) {
447 return nil
448 }
449 if err != nil {
450 return errors.WithStack(err)
451 }
452
453 // older nix profiles have a manifest.nix file present
454 _, err = os.Stat(filepath.Join(dir, "manifest.nix"))
455 if errors.Is(err, fs.ErrNotExist) {
456 return nil
457 }
458 if err != nil {
459 return errors.WithStack(err)
460 }
461
462 return errors.WithStack(os.Remove(profileDir))
463}
464
465func (d *Devbox) installPackages(ctx context.Context, mode installMode) error {
466 defer debug.FunctionTimer().End()

Callers 1

profilePathMethod · 0.85

Calls 2

IsMethod · 0.80
RemoveMethod · 0.45

Tested by

no test coverage detected