From 596dffdae8bace20ce05c2a8d0f55a2d4711a41f Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Tue, 2 Dec 2025 03:45:54 +0800 Subject: [PATCH 1/4] fix: Handle force install properly --- lisp/_prepare.el | 32 +++++++++++++++++++++++--------- src/util.js | 2 +- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lisp/_prepare.el b/lisp/_prepare.el index 5dd83b98..fde7d6b8 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -801,6 +801,15 @@ The optional argument URL-OR-PACKAGE is used in the function `try'." (try (or url-or-package pkg))) "done ✓")) +(defun eask--package-delete-before-install (pkg force) + "Make sure PKG is not presented before installing the latest. + +The argument SHOULD-REINSTALL-P is the permit for this operation." + ;; Recipe can be `nil', handle it. + (when-let* ((rcp (eask-package-desc pkg t))) + (package-delete rcp force) + t)) + (defun eask-package-vc-install (pkg spec) "To vc install the package (PKG) by argument SPEC." (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'." name version) (eask-with-verbosity 'debug ;; Handle `--force` flag. - (when should-reinstall-p (package-delete (eask-package-desc pkg t) t)) + (when should-reinstall-p + (eask--package-delete-before-install pkg t)) ;; Install it. (apply #'package-vc-install spec)) "done ✓"))))) @@ -840,7 +850,8 @@ The optional argument URL-OR-PACKAGE is used in the function `try'." name version) (eask-with-verbosity 'debug ;; Handle `--force` flag. - (when should-reinstall-p (package-delete (eask-package-desc pkg t) t)) + (when should-reinstall-p + (eask--package-delete-before-install pkg t)) ;; XXX: Without ignore-errors guard, it will trigger error ;; ;; Can't find library xxxxxxx.el @@ -874,7 +885,8 @@ The optional argument URL-OR-PACKAGE is used in the function `try'." name version) (eask-with-verbosity 'debug ;; Handle `--force` flag. - (when should-reinstall-p (package-delete (eask-package-desc pkg t) t)) + (when should-reinstall-p + (eask--package-delete-before-install pkg t)) ;; XXX: Without ignore-errors guard, it will trigger error ;; ;; Can't find library xxxxxxx.el @@ -898,11 +910,13 @@ The optional argument URL-OR-PACKAGE is used in the function `try'." "not installed ✗")) (t (eask--pkg-process pkg ; Second call to force refresh the data. - (eask-with-progress - (format " - %sUninstalling %s (%s)... " eask--action-prefix name version) - (eask-with-verbosity 'debug - (package-delete (eask-package-desc pkg t) (eask-force-p))) - "done ✓")))))) + (let ((success)) + (eask-with-progress + (format " - %sUninstalling %s (%s)... " eask--action-prefix name version) + (eask-with-verbosity 'debug + (when (eask--package-delete-before-install pkg (eask-force-p)) + (setq success t))) + (if success "done ✓" "skipped ✗")))))))) (defun eask-package-reinstall (pkg) "Reinstall the package (PKG)." @@ -921,7 +935,7 @@ The optional argument URL-OR-PACKAGE is used in the function `try'." (eask-with-progress (format " - %sReinstalling %s (%s)... " eask--action-prefix name version) (eask-with-verbosity 'debug - (package-delete (eask-package-desc pkg t) t) + (eask--package-delete-before-install pkg t) (eask-ignore-errors (package-install pkg))) "done ✓")))))) diff --git a/src/util.js b/src/util.js index 69c64ffe..57c3ba34 100644 --- a/src/util.js +++ b/src/util.js @@ -252,7 +252,7 @@ async function e_call(argv, script, ...args) { console.log(''); } if (5 <= argv.verbose) { // `all` scope - console.warn('[EXEC] ' + EASK_EMACS + ' ' + cmd.join(' ')); + console.warn('[EXEC] ' + cmd.join(' ')); console.warn(''); } From 56c67c062ed31145536e8cd7961f35cafcff18b4 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Tue, 2 Dec 2025 03:57:39 +0800 Subject: [PATCH 2/4] chore: Remove comment for issue #11 --- lisp/_prepare.el | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/lisp/_prepare.el b/lisp/_prepare.el index fde7d6b8..fe2a1b8d 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -804,7 +804,7 @@ The optional argument URL-OR-PACKAGE is used in the function `try'." (defun eask--package-delete-before-install (pkg force) "Make sure PKG is not presented before installing the latest. -The argument SHOULD-REINSTALL-P is the permit for this operation." +The argument FORCE is passed through to the `package-delete' function." ;; Recipe can be `nil', handle it. (when-let* ((rcp (eask-package-desc pkg t))) (package-delete rcp force) @@ -852,15 +852,8 @@ The argument SHOULD-REINSTALL-P is the permit for this operation." ;; Handle `--force` flag. (when should-reinstall-p (eask--package-delete-before-install pkg t)) - ;; XXX: Without ignore-errors guard, it will trigger error - ;; - ;; Can't find library xxxxxxx.el - ;; - ;; But we can remove this after Emacs 28, since function `find-library-name' - ;; has replaced the function `signal' instead of the `error'. - ;; ;; Install it. - (eask-ignore-errors (package-install-file (expand-file-name file)))) + (package-install-file (expand-file-name file))) "done ✓"))))) (defun eask-package-install (pkg) @@ -887,15 +880,9 @@ The argument SHOULD-REINSTALL-P is the permit for this operation." ;; Handle `--force` flag. (when should-reinstall-p (eask--package-delete-before-install pkg t)) - ;; XXX: Without ignore-errors guard, it will trigger error - ;; - ;; Can't find library xxxxxxx.el - ;; - ;; But we can remove this after Emacs 28, since function `find-library-name' - ;; has replaced the function `signal' instead of the `error'. - ;; ;; Install it. - (eask-ignore-errors (package-install pkg))) + (let ((current-prefix-arg (eask-force-p))) + (package-install pkg))) "done ✓")))))) (defun eask-package-delete (pkg) @@ -936,7 +923,8 @@ The argument SHOULD-REINSTALL-P is the permit for this operation." (format " - %sReinstalling %s (%s)... " eask--action-prefix name version) (eask-with-verbosity 'debug (eask--package-delete-before-install pkg t) - (eask-ignore-errors (package-install pkg))) + (let ((current-prefix-arg (eask-force-p))) + (package-install pkg))) "done ✓")))))) (defun eask-package-desc (name &optional current) @@ -2029,6 +2017,9 @@ Argument ARGS are direct arguments for functions `eask-error' or `eask-warn'." The argument ARGS is passed from the function `eask--error'." (cond ((< emacs-major-version 28) + ;; But we can remove this after Emacs 28, since function `find-library-name' + ;; has replaced the function `signal' instead of the `error'. + ;; ;; Handle https://github.com/emacs-eask/cli/issues/11. (unless (string-prefix-p "Can't find library " (car args)) (setq eask--has-error-p t))) From 9659775280b293fb9714ab5d93674bc2a8892c67 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Tue, 2 Dec 2025 04:07:16 +0800 Subject: [PATCH 3/4] fix: consider flag while exiting --- lisp/_prepare.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/_prepare.el b/lisp/_prepare.el index fe2a1b8d..b78b211b 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -2026,7 +2026,8 @@ The argument ARGS is passed from the function `eask--error'." (t (setq eask--has-error-p t))) ; Just a record. - (when (and (not eask--ignore-error-p) + (when (and eask--has-error-p + (not eask--ignore-error-p) (not (eask-allow-error-p)) ;; Ignore when checking Eask-file. (not (eask-checker-p))) From 2402e2894fa25378625afb351b318d781602129f Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Tue, 2 Dec 2025 04:28:02 +0800 Subject: [PATCH 4/4] docs: Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c062859..41667071 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how * fix: Avoid using white color for light theme ([`8acdc65`](../../commit/8acdc65f464414ac2ba591d600dbca55ac7a5952)) * fix: Use `kill-current-buffer` instead ([#331](../../pull/331)) * fix: eask analyze should exit with 1 on errors ([#359](../../pull/359)) +* fix: Handle force install properly ([#373](../../pull/373)) ## 0.11.x > Released Apr 03, 2025