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

'jump to definition' not working on cider-connect with remote embed repl server. #2148

Closed
soulawaker opened this issue Jan 1, 2018 · 10 comments
Labels

Comments

@soulawaker
Copy link
Contributor

I don't know it is bug or not, yet.

Expected behavior

Jumping to the definition that required by ns.

Actual behavior

Not jumping. symbol: prompted.

Steps to reproduce the problem

Add [cider/cider-nrepl "0.17.0-SNAPSHOT"] dependency to project.clj.
Add [cider.nrepl :refer [cider-nrepl-handler]] to ns in clj file that send its handler to an embed REPL server.
Find remote project folder and files by Emacs Tramp.
cider-connect on any remote project file to remote embed REPL server.
Connection established. 'cider-repl buffer' worked fine.
Try jump to definition in any function from required external namespace.
Failed and symbol: prompted.

This is extremely important! Providing us with a reliable way to reproduce
a problem will expedite its solution.

Environment & Version information

CIDER version information

0.17.0-SNAPSHOT (20171228.1254), nREPL 0.2.12
Clojure 1.8.0, Java 1.8.0_151

Lein/Boot version

Lein 2.8.1

Emacs version

24.5

Operating system

Elementary OS Loki based on Ubuntu 16.04

@bbatsov
Copy link
Member

bbatsov commented Jan 1, 2018

Can you, please, post here the message exchange between CIDER and nREPL (as described here http://cider.readthedocs.io/en/latest/troubleshooting/)? This will give us a much better idea about the exact nature of the problem.

@soulawaker
Copy link
Contributor Author

soulawaker commented Jan 1, 2018

Sure. You mean *nREPL-messages* buffer?
I paste it below.
The remote REPL server run in docker container in remote machine.
I've tested the Luminus-framework example project, guestbook.

(-->
  id         "14"
  op         "info"
  session    "b046f262-bbe1-4926-bd39-1af0d21260be"
  time-stamp "2018-01-01 19:04:21.099183274"
  ns         "guestbook.db.core"
  symbol     "conman/bind-connection"
)
(<--
  id           "14"
  session      "b046f262-bbe1-4926-bd39-1af0d21260be"
  time-stamp   "2018-01-01 19:04:21.127424709"
  arglists-str "[conn & filenames]"
  column       1
  file         "jar:file:/root/.m2/repository/conman/conman/0.6.2/conman-0.6..."
  line         31
  macro        "true"
  name         "bind-connection"
  ns           "conman.core"
  resource     "conman/core.clj"
  status       ("done")
)

Add another sample

(-->
  id         "22"
  op         "info"
  session    "13085013-a158-41f6-ba4b-1f8ba37c72ac"
  time-stamp "2018-01-01 22:48:11.441079063"
  ns         "guestbook.test.db.core"
  symbol     "mount/start"
)
(<--
  id         "22"
  session    "13085013-a158-41f6-ba4b-1f8ba37c72ac"
  time-stamp "2018-01-01 22:48:11.457146616"
  status     ("done" "no-info")
)

@bbatsov
Copy link
Member

bbatsov commented Jan 1, 2018

The first example seems fine, so IMO this should take you to the source.

The second is odd - seems there's no metadata for mount/start. Is this var evaluated?

Regarding the first example - it'd be nice if you debugged the cider-find-var command as described here https://cider.readthedocs.io/en/latest/troubleshooting/#debugging-cider-commands

I'm pretty puzzled by the fact that you got all the data you needed but the lookup is not working.

@soulawaker
Copy link
Contributor Author

soulawaker commented Jan 2, 2018

What I found is that cider-find-file in cider--find-buffer-for-file is not working properly in its place. This happened only in remote machine with Tramp, not local repository.

For example, here is nrepl-messages.

(-->
  id         "30"
  op         "info"
  session    "57dd5648-730e-491a-a815-1cd30a676312"
  time-stamp "2018-01-02 23:52:54.496649712"
  ns         "guestbook.routes.home"
  symbol     "db/save-message!"
)
(<--
  id         "30"
  session    "57dd5648-730e-491a-a815-1cd30a676312"
  time-stamp "2018-01-02 23:52:54.556431954"
  doc        "creates a new message"
  file       "file:/root/guestbook/src/clj/guestbook/db/core.clj"
  name       "save-message!"
  ns         "guestbook.db.core"
  status     ("done")
)

I used the Edebugger to watch steps from cider-find-var.
Then I start jump to definition with the symbol db/save-message!
(Oh, I used Spacemacs based on Emacs 24.5. Sorry for late report if it is related.)
This takes the process to an weird prompt No comment syntax is defined. Use:.
Even it can't be canceled by C-g.

And some other weird things happened in cider-find-file.
I will test more sometimes.

@bbatsov bbatsov added the bug label Jan 2, 2018
@soulawaker
Copy link
Contributor Author

soulawaker commented Jan 3, 2018

In cider-find-file, match-string malfunctions.
It received sane parameters then evaluated it to nil.
According to my watch, all two parts used it do such abnormal behavior.

 (cond ((string-match "^file:\\(.+\\)" url)
         (when-let* ((file (cider--url-to-file (match-string 1 url)))  <---- Here, first!
                     (path (cider--file-path file)))
           (find-file-noselect path)))
        ((string-match "^\\(jar\\|zip\\):\\(file:.+\\)!/\\(.+\\)" url)
         (when-let* ((entry (match-string 3 url))                       <---- And second!
                     (file  (cider--url-to-file (match-string 2 url)))
                     (path  (cider--file-path file))
                     (name  (format "%s:%s" path entry)))

But those parts, not calling cider-find-file defun, are all fine on test in *scratch* buffer. The parameter is the same as my previous comment, "file:/root/guestbook/src/clj/guestbook/db/core.clj".
Why this happen? I can't reason out instantly.

@bbatsov
Copy link
Member

bbatsov commented Jan 3, 2018

So, basically you're saying (match-string 1/3 url) returns nil, right? I can't imagine how this might be happening if the string-match succeeds. The regular expression parentheses seem fine to me.

@soulawaker
Copy link
Contributor Author

Yes, Edebugger shows that string-match return 0 but match-string return nil. Don't you reproduce it in remote environment?

@soulawaker
Copy link
Contributor Author

soulawaker commented Jan 4, 2018

Until yesterday I had tried just edebug-step-mode. Today I've tried edebug-set-breakpoint and edebug-forward-sexp. I thought two method show the same result but not. match-string returned nil with the former. With the latter, it returns normal result. But in the process, an error, "Error running timer `auto-revert-buffers': (wrong-type-argument stringp nil)", is occurred. Then, this takes me finally to an empty buffer which name is what I want.

@soulawaker
Copy link
Contributor Author

I found and finally fixed it. After more examinations I would like to send PR.

@bbatsov
Copy link
Member

bbatsov commented Jan 5, 2018

@soulawaker Happy to hear this! Looking forward to that PR!

soulawaker added a commit to soulawaker/cider that referenced this issue Jan 7, 2018
soulawaker added a commit to soulawaker/cider that referenced this issue Jan 7, 2018
soulawaker added a commit to soulawaker/cider that referenced this issue Jan 7, 2018
soulawaker added a commit to soulawaker/cider that referenced this issue Jan 7, 2018
soulawaker added a commit to soulawaker/cider that referenced this issue Jan 7, 2018
soulawaker added a commit to soulawaker/cider that referenced this issue Jan 8, 2018
soulawaker added a commit to soulawaker/cider that referenced this issue Jan 11, 2018
soulawaker added a commit to soulawaker/cider that referenced this issue Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants