diff --git a/cider-util.el b/cider-util.el index 196dfc714..69db48af5 100644 --- a/cider-util.el +++ b/cider-util.el @@ -518,7 +518,7 @@ Any other value is just returned." ;;; Files (defun cider--ensure-executable (file) - (with-demoted-errors "Error trying to make file executable:\n %s" + (with-demoted-errors "Error while trying to make file executable:\n %s" (when (or (file-executable-p file) (and (set-file-modes file "u+x") (file-executable-p file))) @@ -529,38 +529,36 @@ Any other value is just returned." (concat ".cider__" (file-name-nondirectory file) "__"))) (defun cider--make-nearby-temp-copy (file) - (with-demoted-errors "Failed to copy to temporary file:\n %s" - (let* ((default-directory (or (clojure-project-dir) default-directory)) - ;; Note: (temporary-file-directory) uses `default-directory' as fallback. - (new-file (file-name-concat (temporary-file-directory) - (cider--make-temp-name file)))) - (copy-file file new-file :exists-ok nil nil :keep-permissions) - new-file))) + (let* ((default-directory (or (clojure-project-dir) default-directory)) + ;; Note: (temporary-file-directory) uses `default-directory' as fallback. + (new-file (file-name-concat (temporary-file-directory) + (cider--make-temp-name file)))) + (copy-file file new-file :exists-ok nil nil :keep-permissions) + new-file)) (defun cider--inject-self-delete (bash-script) - (with-demoted-errors "Failed to inject self-delete string:\n %s" - (let (;; Don't create any temporary files. - (remote-file-name-inhibit-locks t) - (remote-file-name-inhibit-auto-save-visited t) - (backup-inhibited t) - (auto-save-default nil) - ;; Disable version-control check - (vc-handled-backends nil)) - (with-temp-buffer - (insert-file-contents bash-script) - ;; inject after the first line, assuming it is the shebang - (goto-char (point-min)) - (skip-chars-forward "^\n") - (insert "\n") - (insert (format - "trap 'ARG=$? + (let (;; Don't create any temporary files. + (remote-file-name-inhibit-locks t) + (remote-file-name-inhibit-auto-save-visited t) + (backup-inhibited t) + (auto-save-default nil) + ;; Disable version-control check + (vc-handled-backends nil)) + (with-temp-buffer + (insert-file-contents bash-script) + ;; inject after the first line, assuming it is the shebang + (goto-char (point-min)) + (skip-chars-forward "^\n") + (insert "\n") + (insert (format + "trap 'ARG=$? rm -v %s echo \"cider: Cleaned up temporary script after use.\" exit $ARG ' EXIT" - (file-local-name bash-script))) - (write-file bash-script)) - bash-script))) + (file-local-name bash-script))) + (write-file bash-script)) + bash-script)) ;;; Help mode diff --git a/cider.el b/cider.el index e21d31d2a..2571c76da 100644 --- a/cider.el +++ b/cider.el @@ -438,10 +438,11 @@ use. The search for is handled by tramp and falls back to (location (concat cider-dir name)) (script (cider--ensure-executable location))) (if (file-remote-p default-directory) - (thread-first - (cider--make-nearby-temp-copy script) - (cider--ensure-executable) - (cider--inject-self-delete)) + (with-demoted-errors "cider: Failed to init enrich-classpath on remote: %s" + (thread-first + (cider--make-nearby-temp-copy script) + (cider--ensure-executable) + (cider--inject-self-delete))) script))) (defun cider--jack-in-resolve-command-enrich (project-type)