Skip to content

Commit

Permalink
fix: if venv installation fails partway through, we leave around inco…
Browse files Browse the repository at this point in the history
…mplete venv cache dir

Fixes #570
Signed-off-by: Nick Mitchell <[email protected]>
  • Loading branch information
starpit committed Nov 26, 2024
1 parent ca83f78 commit 6802d4d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/runtime/needs/install_requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,16 @@ pip3 install %s %s -r %s %s 1>&2`, venvPath, venvPath, verboseFlag, nocache, qui
cmd.Stdout = os.Stderr
}
cmd.Stderr = os.Stderr
return path, cmd.Run()

if err := cmd.Run(); err != nil {
// Clean up the venv cache directory, since we failed at populating it
if err := os.RemoveAll(venvPath); err != nil {
fmt.Fprintln(os.Stderr, "Unable to clean up venv cache directory after pip install failure", err)
}
return path, err
}

return path, nil
}

func getSHA256Sum(requirements []byte) (string, error) {
Expand Down

0 comments on commit 6802d4d

Please sign in to comment.