@@ -801,6 +801,15 @@ The optional argument URL-OR-PACKAGE is used in the function `try'."
801801 (try (or url-or-package pkg)))
802802 " done ✓" ))
803803
804+ (defun eask--package-delete-before-install (pkg force )
805+ " Make sure PKG is not presented before installing the latest.
806+
807+ The argument FORCE is passed through to the `package-delete' function."
808+ ; ; Recipe can be `nil' , handle it.
809+ (when-let* ((rcp (eask-package-desc pkg t )))
810+ (package-delete rcp force)
811+ t ))
812+
804813(defun eask-package-vc-install (pkg spec )
805814 " To vc install the package (PKG) by argument SPEC."
806815 (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
@@ -818,7 +827,8 @@ The optional argument URL-OR-PACKAGE is used in the function `try'."
818827 name version)
819828 (eask-with-verbosity 'debug
820829 ; ; Handle `--force` flag.
821- (when should-reinstall-p (package-delete (eask-package-desc pkg t ) t ))
830+ (when should-reinstall-p
831+ (eask--package-delete-before-install pkg t ))
822832 ; ; Install it.
823833 (apply #'package-vc-install spec))
824834 " done ✓" )))))
@@ -840,16 +850,10 @@ The optional argument URL-OR-PACKAGE is used in the function `try'."
840850 name version)
841851 (eask-with-verbosity 'debug
842852 ; ; Handle `--force` flag.
843- (when should-reinstall-p (package-delete (eask-package-desc pkg t ) t ))
844- ; ; XXX: Without ignore-errors guard, it will trigger error
845- ; ;
846- ; ; Can't find library xxxxxxx.el
847- ; ;
848- ; ; But we can remove this after Emacs 28, since function `find-library-name'
849- ; ; has replaced the function `signal' instead of the `error' .
850- ; ;
853+ (when should-reinstall-p
854+ (eask--package-delete-before-install pkg t ))
851855 ; ; Install it.
852- (eask-ignore-errors ( package-install-file (expand-file-name file) )))
856+ (package-install-file (expand-file-name file)))
853857 " done ✓" )))))
854858
855859(defun eask-package-install (pkg )
@@ -874,16 +878,11 @@ The optional argument URL-OR-PACKAGE is used in the function `try'."
874878 name version)
875879 (eask-with-verbosity 'debug
876880 ; ; Handle `--force` flag.
877- (when should-reinstall-p (package-delete (eask-package-desc pkg t ) t ))
878- ; ; XXX: Without ignore-errors guard, it will trigger error
879- ; ;
880- ; ; Can't find library xxxxxxx.el
881- ; ;
882- ; ; But we can remove this after Emacs 28, since function `find-library-name'
883- ; ; has replaced the function `signal' instead of the `error' .
884- ; ;
881+ (when should-reinstall-p
882+ (eask--package-delete-before-install pkg t ))
885883 ; ; Install it.
886- (eask-ignore-errors (package-install pkg)))
884+ (let ((current-prefix-arg (eask-force-p)))
885+ (package-install pkg)))
887886 " done ✓" ))))))
888887
889888(defun eask-package-delete (pkg )
@@ -898,11 +897,13 @@ The optional argument URL-OR-PACKAGE is used in the function `try'."
898897 " not installed ✗" ))
899898 (t
900899 (eask--pkg-process pkg ; Second call to force refresh the data.
901- (eask-with-progress
902- (format " - %s Uninstalling %s (%s )... " eask--action-prefix name version)
903- (eask-with-verbosity 'debug
904- (package-delete (eask-package-desc pkg t ) (eask-force-p)))
905- " done ✓" ))))))
900+ (let ((success ))
901+ (eask-with-progress
902+ (format " - %s Uninstalling %s (%s )... " eask--action-prefix name version)
903+ (eask-with-verbosity 'debug
904+ (when (eask--package-delete-before-install pkg (eask-force-p))
905+ (setq success t )))
906+ (if success " done ✓" " skipped ✗" ))))))))
906907
907908(defun eask-package-reinstall (pkg )
908909 " Reinstall the package (PKG)."
@@ -921,8 +922,9 @@ The optional argument URL-OR-PACKAGE is used in the function `try'."
921922 (eask-with-progress
922923 (format " - %s Reinstalling %s (%s )... " eask--action-prefix name version)
923924 (eask-with-verbosity 'debug
924- (package-delete (eask-package-desc pkg t ) t )
925- (eask-ignore-errors (package-install pkg)))
925+ (eask--package-delete-before-install pkg t )
926+ (let ((current-prefix-arg (eask-force-p)))
927+ (package-install pkg)))
926928 " done ✓" ))))))
927929
928930(defun eask-package-desc (name &optional current )
@@ -2015,13 +2017,17 @@ Argument ARGS are direct arguments for functions `eask-error' or `eask-warn'."
20152017
20162018The argument ARGS is passed from the function `eask--error' ."
20172019 (cond ((< emacs-major-version 28 )
2020+ ; ; But we can remove this after Emacs 28, since function `find-library-name'
2021+ ; ; has replaced the function `signal' instead of the `error' .
2022+ ; ;
20182023 ; ; Handle https://github.com/emacs-eask/cli/issues/11.
20192024 (unless (string-prefix-p " Can't find library " (car args))
20202025 (setq eask--has-error-p t )))
20212026 (t
20222027 (setq eask--has-error-p t ))) ; Just a record.
20232028
2024- (when (and (not eask--ignore-error-p)
2029+ (when (and eask--has-error-p
2030+ (not eask--ignore-error-p)
20252031 (not (eask-allow-error-p))
20262032 ; ; Ignore when checking Eask-file.
20272033 (not (eask-checker-p)))
0 commit comments