Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xref-find-definitions: Not a Tramp file name #3235

Closed
manuel-uberti opened this issue Aug 5, 2022 · 5 comments
Closed

xref-find-definitions: Not a Tramp file name #3235

manuel-uberti opened this issue Aug 5, 2022 · 5 comments

Comments

@manuel-uberti
Copy link
Contributor

Expected behavior

M-. on a symbol required from another namespace takes me to that name space to check its definition.

Actual behavior

M-. prints the following message:

tramp-error: Not a Tramp file name: "<path-to-file>"

Steps to reproduce the problem

  • emacs -Q
  • M-x package-initialize
  • jack-in into a Clojure project (I used this) with C-c C-x j j
  • visit a namespace (I visited this one)
  • hit M-. on function you are using which belongs to a different namespace (e.g., I used aims/select-by-id)

Environment & Version information

CIDER version information

;; CIDER 1.5.0-snapshot (package: 1.5.0snapshot.0.20220731.52230), nREPL 0.9.0
;; Clojure 1.11.1, Java 11.0.16

Lein / Clojure CLI version

Clojure CLI version 1.11.1.1105

Emacs version

GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2022-08-05

Operating system

Ubuntu 22.04.1 LTS

JDK distribution

OpenJDK 11.0.16

@andreyorst
Copy link
Contributor

andreyorst commented Aug 8, 2022

I believe I have the same issue but with cider-connect-clj:

tramp-error: Not a Tramp file name: "<path/to/project/root>"

Emacs version is GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.29, cairo version 1.17.4) of 2022-08-08 Emacs was checked out at 9b661ff1a8e0fc3fc809a42a187356d6cb5ad2c9

By removing user-error from debug-ignorred-errors and enabling debug-on-error I've got this stack trace:

Debugger entered--Lisp error: (user-error "Not a Tramp file name: \"~/vaiv/\"")
  signal(user-error ("Not a Tramp file name: \"~/vaiv/\""))
  tramp-error(nil user-error "Not a Tramp file name: \"%s\"" "~/vaiv/")
  apply(tramp-error nil user-error "Not a Tramp file name: \"%s\"" "~/vaiv/")
  tramp-user-error(nil "Not a Tramp file name: \"%s\"" "~/vaiv/")
  tramp-dissect-file-name("~/vaiv/")
  tramp-handle-file-exists-p("~/vaiv/")
  cider--client-tramp-filename("~/vaiv/")
  cider--file-path("~/vaiv/")
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_77>("~/vaiv/")
  cider-locate-running-nrepl-ports("~/vaiv/")
  cider--infer-ports("localhost" (...)) ; list of IPs in place of '...'
  cider-select-endpoint()
  cider--update-host-port((:project-dir "~/vaiv/"))
  cider-connect-clj(nil)
  funcall-interactively(cider-connect-clj nil)
  call-interactively(cider-connect-clj nil nil)
  command-execute(cider-connect-clj)

For some reason this can't be done for xref-find-definitions, perhaps it catches the error somewhere and only displays a message.

@andreyorst
Copy link
Contributor

This fixed the issue for me:

From 825156d87b0f11930773ae3d9e735ff6eb81a2ef Mon Sep 17 00:00:00 2001
From: Andrey Listopadov <andreyorst@gmail.com>
Date: Mon, 8 Aug 2022 12:35:48 +0300
Subject: [PATCH] fix CIDER TRAMP integration

---
 cider-common.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cider-common.el b/cider-common.el
index c0e81324..981f4482 100644
--- a/cider-common.el
+++ b/cider-common.el
@@ -263,7 +263,8 @@ otherwise, nil."
   (let* ((buffer (or buffer (current-buffer)))
          (name (replace-regexp-in-string "^file:" "" name))
          (name (concat (cider-tramp-prefix buffer) name)))
-    (if (tramp-handle-file-exists-p name)
+    (if (and (tramp-file-name-p name)
+             (tramp-handle-file-exists-p name))
         name)))
 
 (defun cider--server-filename (name)
-- 
2.36.1

@manuel-uberti
Copy link
Contributor Author

Awesome, can you open a PR about this? @bbatsov what do you think?

@bbatsov
Copy link
Member

bbatsov commented Aug 8, 2022

The proposed fix looks good to me.

@bbatsov bbatsov closed this as completed in 9577dbb Aug 8, 2022
@manuel-uberti
Copy link
Contributor Author

Just FYI: tested the fix today and it works as expected. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants