raco pkg remove: check for all named packages before removing any

Closes #3846
This commit is contained in:
Matthew Flatt 2021-05-24 09:44:47 -06:00
parent 4be7220703
commit 095937b324
3 changed files with 13 additions and 1 deletions

View File

@ -34,6 +34,10 @@
(shelly-install "remove test with immediately redundant package name"
"test-pkgs/pkg-test1.zip"
"pkg-test1 pkg-test1")
(shelly-install "remove test where second in given list does not exist"
"test-pkgs/pkg-test1.zip"
$ "raco pkg remove pkg-test1 not-there" =exit> 1 =stderr> #rx"not currently installed"
$ "racket -e '(require pkg-test1)'" =exit> 0)
(shelly-install "remove of dep fails"
"test-pkgs/pkg-test1.zip"
$ "raco pkg show -l -u -a" =stdout> #rx"Package +Checksum +Source\npkg-test1 +[a-f0-9.]+ +\\(file .+/test-pkgs/pkg-test1.zip\"\\)\n"

View File

@ -25,7 +25,8 @@
update-auto
scope->links-file
installed-pkg-table
installed-pkg-names)
installed-pkg-names
pkg-not-installed)
(define (read-pkg-db)
(unless (pkg-lock-held)

View File

@ -85,6 +85,13 @@
(list->set all-pkgs))
(define metadata-ns (make-metadata-namespace))
(define in-pkgs (remove-duplicates given-pkgs))
;; Check that all packages are installed, so we don't remove half of
;; them and leave things in an potentialy inconsistent state:
(for ([pkg (in-list in-pkgs)])
(unless (set-member? all-pkgs pkg)
(pkg-not-installed pkg db)))
(define remove-pkgs
(if auto?
;; compute fixpoint: