fix: lake: do not delete path dependencies (#5878)

Fixes a serious issue where Lake would delete path dependencies when
attempting to cleanup a dependency required with an incorrect name.

Closes #5876. Originally part of #5684, but also independently
discovered by François.
This commit is contained in:
Mac Malone 2024-10-29 22:31:20 -04:00 committed by GitHub
parent 5e7d02e4ea
commit 4714f84fb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -210,10 +210,11 @@ def updateDep
| .git (inputRev? := some rev) .. => s!" @ {repr rev}"
| _ => ""
logError (stdMismatchError depPkg.name.toString rev)
if let .error e ← IO.FS.removeDirAll depPkg.dir |>.toBaseIO then -- cleanup
-- Deleting git repositories via IO.FS.removeDirAll does not work reliably on Windows
logError s!"'{dep.name}' was downloaded incorrectly; \
you will need to manually delete '{depPkg.dir}': {e}"
if matDep.manifestEntry.src matches .git .. then
if let .error e ← IO.FS.removeDirAll depPkg.dir |>.toBaseIO then -- cleanup
-- Deleting git repositories via IO.FS.removeDirAll does not work reliably on Windows
logError s!"'{dep.name}' was downloaded incorrectly; \
you will need to manually delete '{depPkg.dir}': {e}"
error s!"{pkg.name}: package '{depPkg.name}' was required as '{dep.name}'"
return depPkg