cider icon indicating copy to clipboard operation
cider copied to clipboard

Problem with jack-in and tramp

Open carrete opened this issue 8 years ago • 19 comments

When I have a buffer open, project.clj for example, over a tramp connection and I try to jack-in, CIDER somehow replaces lein with the tramp buffer name. For example:

Starting nREPL server via /ssh\:root\@localhost\#32808\: update-in :dependencies conj \[acyclic/squiggly-clojure\ \"0.1.5\"\] -- update-in :dependencies conj \[org.clojure/tools.nrepl\ \"0.2.12\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.13.0\"\] -- repl :headless...
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: /bin/sh: 2: /ssh:root@localhost#32808:: not found

Expected behavior

When M-x cider-jack-in or M-x cider-jack-in-clojurescript is run in a tramp buffer CIDER should use lein to start an nrepl server on the command-line.

Actual behavior

CIDER uses the tramp buffer name in place of lein on the command-line.

Steps to reproduce the problem

  1. Use tramp to open a buffer.
  2. In this buffer run M-x cider-jack-in or M-x cider-jack-in-clojurescript.

Environment & Version information

CIDER version information

CIDER 0.13

Lein/Boot version

lein 2.6.1

Emacs version

25.1.1

Operating system

macOS Sierra

carrete avatar Sep 28 '16 20:09 carrete

@benedekfazekas Can you look into this? Perhaps you didn't took into account remote buffers in the new jack-in logic or something?

bbatsov avatar Sep 29 '16 05:09 bbatsov

will have a look

benedekfazekas avatar Sep 29 '16 05:09 benedekfazekas

had a look. I don't think it is a regression actually. It seems to me that jack in over tramp is kinda half baked, this todo comment perhaps seconds that?! https://github.com/clojure-emacs/cider/blob/master/cider.el#L686

I may be misunderstanding the code but I assume this:

 (when-let ((command (or (file-remote-p default-directory) 
                         (executable-find cider-lein-command)
                         (executable-find (concat cider-lein-command ".bat")))))
    (shell-quote-argument command))

will never work for a remote project.clj as it tries to run the remote default directory as a lein command?!

benedekfazekas avatar Oct 10 '16 10:10 benedekfazekas

Oh, shit - yeah. I now remember I couldn't quickly figure out how to check for the executable on the remote host. But I remember this check was actually fixing something. :-)

bbatsov avatar Oct 10 '16 11:10 bbatsov

i can put this on my list but cljr hacking comes first now. as a temporary measure we can show an error if the file is remote I guess and point the user towards using cider-connect to a remote REPL i suppose. there could be also some rabbit holes with remote files (have not grepped cljr issues but we had some problems with them afair)

benedekfazekas avatar Oct 10 '16 13:10 benedekfazekas

as a temporary measure we can show an error if the file is remote I guess and point the user towards using cider-connect to a remote REPL

Could I set a variable instead to specify the remote command?

carrete avatar Oct 12 '16 11:10 carrete

I've committed a potential workaround - on remote hosts we simply assume the command we need is available. Please, try it out.

bbatsov avatar Oct 12 '16 15:10 bbatsov

@bbatsov I don't have a direct answer to your question...but I know that ssh.el tab completes commands correctly. Looking at ssh-tab-or-complete shows it calls completion-at-point. Not sure that's going to help.

zenspider avatar Oct 12 '16 23:10 zenspider

I've committed a potential workaround - on remote hosts we simply assume the command we need is available. Please, try it out.

Thanks @bbatsov. I dropped the new cider.el on top of cider.el v0.13, restarted emacs, opened project.clj over tramp, then jacked-in, and still the same problem. What more can I provide to you to help with this?

carrete avatar Oct 13 '16 16:10 carrete

you might have it compiled. remove cider.elc if it is in the directory

On 13 Oct 2016 5:29 p.m., "Formerly known as tvaughan" < [email protected]> wrote:

I've committed a potential workaround - on remote hosts we simply assume the command we need is available. Please, try it out.

Thanks @bbatsov https://github.com/bbatsov. I dropped the new cider.el on top of cider.el v0.13, restarted emacs, opened project.clj over tramp, then jacked-in, and still the same problem. What more can I provide to you to help with this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/clojure-emacs/cider/issues/1854#issuecomment-253565525, or mute the thread https://github.com/notifications/unsubscribe-auth/AA9Pnvx9ot5lrzIuWHJz5bksFESakN1Yks5qzlxegaJpZM4KJP9s .

benedekfazekas avatar Oct 13 '16 17:10 benedekfazekas

I can't imagine how my fix wouldn't be working - it basically returns the name of the command matching the project's type, without trying to resolve it. If this binary exists on the remote host everything should work just fine.

bbatsov avatar Oct 13 '16 19:10 bbatsov

you might have it compiled. remove cider.elc if it is in the directory

Damnit. That was it. It works! Thanks!

carrete avatar Oct 13 '16 22:10 carrete

Seems that the proper solution for this would be the use of tramp-find-executable (part of the built-in library tramp-sh.el.). Down the road we should leverage this.

bbatsov avatar Oct 14 '16 08:10 bbatsov

I've tried cider-jack-in in remote machine source.

Tramp: Opening connection for <remote host info> using ssh...
Tramp: Sending command `exec ssh -q   -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none <remote host info>'
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on <remote host info>
Tramp: Opening connection for <remote host info> using ssh...done
Making nrepl-create-client-buffer-function local to *nrepl-server guestbook* while let-bound!
Making nrepl-use-this-as-repl-buffer local to *nrepl-server guestbook* while let-bound!
Starting nREPL server via lein update-in :dependencies conj \[org.clojure/tools.nrepl\ \"0.2.13\"\ \:exclusions\ \[org.clojure/clojure\]\] -- update-in :plugins conj \[refactor-nrepl\ \"2.4.0-SNAPSHOT\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.17.0-SNAPSHOT\"\] -- repl :headless :host ::...
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: /bin/sh: 2: lein: not found

error in process sentinel: Could not start nREPL server: /bin/sh: 2: lein: not found

I've traced from cider-jack-in to nrepl-server-sentinel. Edebugger shows that set-process-coding-system's parameter, serv-proc has the message, "Input file descriptor of nrepl-server closed". So, I guess this problem is related set-process-sentinel. I'm stuck here.

BTW, I already report cider-connect related issue. I heartily thank you for developing cider. I want to work directly in remote service server. Could I work it with cider?

soulawaker avatar Jan 03 '18 16:01 soulawaker

I see that lein is not your exec-path on the remote server. I guess that's what the cause of your problem.

bbatsov avatar Jan 03 '18 17:01 bbatsov

I already set lein to exec-path on the remote server.

soulawaker avatar Jan 04 '18 02:01 soulawaker

So, you did something like this https://stackoverflow.com/questions/26630640/tramp-ignores-tramp-remote-path and you verified that tramp sees the remote lein?

bbatsov avatar Jan 04 '18 07:01 bbatsov

I'm very sorry. My PATH setting placed in .profile. So I thought Tramp should check this naturally. But it ignored. I was thoughtless. Thank you for the hint.

soulawaker avatar Jan 04 '18 08:01 soulawaker

FYI, with a recent version of cider, I tried to connect to a server and got this message:

nrepl-connect: [nREPL] Direct connection to my.server:43681 failed; try setting ‘nrepl-use-ssh-fallback-for-remote-hosts’ to t

After putting that setting in place, the remote connection works for me.

holtzermann17 avatar Aug 27 '19 09:08 holtzermann17

See https://github.com/clojure-emacs/cider/issues/2703#issuecomment-1679387356

vemv avatar Aug 15 '23 18:08 vemv