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

prblems launching CIDER through Podman TRAMP integration #3303

Closed
andreyorst opened this issue Dec 28, 2022 · 5 comments
Closed

prblems launching CIDER through Podman TRAMP integration #3303

andreyorst opened this issue Dec 28, 2022 · 5 comments

Comments

@andreyorst
Copy link
Contributor

Expected behavior

In the upcoming Emacs 29, it will be possible to use TRAMP to edit files inside Docker and Podman containers. When editing a such file, the path looks like this:

/podman:ubuntu-20-04:~/path/to/file.clj

I'd expect CIDER to work the same way how it works when editing files over SSH on the remote machine, however, upon calling cider-jack-in an error occurs.

Actual behavior

Toggling the debug on error, shows me the following stack trace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  nrepl--ssh-tunnel-connect("ubuntu-20-04" 37095)
  nrepl-connect("ubuntu-20-04" 37095)
  nrepl-start-client-process("ubuntu-20-04" 37095 #<process nrepl-server> #f(compiled-function (_) #<bytecode -0x1ac3296481b2b3d5>) nil)
  cider-nrepl-connect((:project-dir "/podman:ubuntu-20-04:~/Projects/clj-utils/" :jack-in-cmd "lein update-in :dependencies conj \\[nrepl/nrepl\\ \\..." :host "ubuntu-20-04" :port 37095 :project-dir "/podman:ubuntu-20-04:~/Projects/clj-utils/" :server #<process nrepl-server> :server-command "lein update-in :dependencies conj \\[nrepl/nrepl\\ \\..." :repl-init-function nil :repl-type clj :session-name nil))
  cider-connect-sibling-clj((:project-dir "/podman:ubuntu-20-04:~/Projects/clj-utils/" :jack-in-cmd "lein update-in :dependencies conj \\[nrepl/nrepl\\ \\...") #<buffer  *nrepl-server Projects/clj-utils:localhost*>)
  #f(compiled-function (server-buffer) #<bytecode 0x16dd942a8941f890>)(#<buffer  *nrepl-server Projects/clj-utils:localhost*>)
  nrepl-server-filter(#<process nrepl-server> "nREPL server started on port 37095 on host localho...")

So it appears, cider issues an ssh connection to a Podman container.
There's also another error that can appear when connection is issued via Podman:

[2022-12-28T10:54:43.285] Tramp: Opening connection nrepl-server for ubuntu using podman...
[2022-12-28T10:54:43.472] Tramp: Opening connection nrepl-server for ubuntu using podman...done
[2022-12-28T10:54:43.489] [nREPL] Starting server via clojure -J-XX:-OmitStackTraceInFastThrow -Sdeps '{:deps {nrepl/nrepl {:mvn/version "1.0.0"} cider/cider-nrepl {:mvn/version "0.29.0"} refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: nil ("exited abnormally with code 127")
error in process sentinel: Could not start nREPL server: nil ("exited abnormally with code 127")

I'm not sure what's causing one or another.

Steps to reproduce the problem

To easily create a container, use distrobox:

  • distrobox create -i ubuntu:20.04 -n ubuntu
    It will make it possible to access your home directory in the container, so all your projects are available there.
  • distrobox enter ubuntu to initialize container
  • In regularly running Emacs 29 (e.g. outside container): C-x C-f /podman:ubuntu:path/to/file.clj
  • M-x cider-jack-in

Environment & Version information

CIDER version information

Include here the version string displayed when
CIDER's REPL is launched. Here's an example:

;; CIDER 1.6.0-snapshot (package: 1.6.0-snapshot), nREPL 1.0.0
;; Clojure 1.11.1, Java 17.0.5

Lein / Clojure CLI version

Leiningen 2.9.10 on Java 17.0.5 OpenJDK 64-Bit Server VM

Emacs version

GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) of 2022-12-19

Operating system

Fedora 37

@bbatsov
Copy link
Member

bbatsov commented Jan 30, 2023

It'd be nice to run the command generated by cider-jack-in (clojure -J-XX:-OmitStackTraceInFastThrow -Sdeps '{:deps {nrepl/nrepl {:mvn/version "1.0.0"} cider/cider-nrepl {:mvn/version "0.29.0"} refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl) manually and see what's the actual error that's happening. Right now it's impossible to tell from the Emacs stacktrace.

@bbatsov
Copy link
Member

bbatsov commented Jan 30, 2023

Actually, after reading the second time it seems that nREPL actually starts, but the SSH tunnel doesn't work, right? Still, it'd be nice to see what's the underlying error.

There's also another error that can appear when connection is issued via Podman:

I have to admit that I don't know what Podman is, so I'd definitely appreciate the help of someone familiar with it. :-)

@andreyorst
Copy link
Contributor Author

I didn't had this problem anymore so I'll close it for now. Will reopen it if I find ways to reproduce it

@caadr
Copy link
Contributor

caadr commented Oct 18, 2023

I just ran into the stringp-error while trying to play with my new raspberry pi. No docker / podman.

find-file /ssh:****@pi.local:~/hello/deps.edn [containing only "{}"]
M-x cider-jack-in

[nREPL] Starting server via clojure -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.0.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.40.0\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[cider.nrepl/cider-middleware\]\"\]\}\}\} -M:cider/nrepl
[nREPL] server started on 40699
...
[nREPL] Falling back to SSH tunneled connection ...
[nREPL] Establishing SSH tunneled connection to pi.local:40699 ...
error in process filter: Wrong type argument: stringp, nil

The problem is that nrepl--ssh-tunnel-connect tries to string-match on (buffer-file-name) - which is nil, because the current execution context is the nrepl buffer:

;; edebug: (current-buffer)
#<buffer *nrepl-server hello:localhost*<13>>

Is this expected / did something change since this feature was introduced (#3264)?

To confirm, I tried

-  (let* ((current-buf (buffer-file-name))
+  (let* ((current-buf (or (buffer-file-name)
+                          (buffer-file-name (window-buffer (selected-window)))))

... which works, but only if one doesn't switch windows while cider is booting up.

A less flaky approach would be to just pass down the buffer from which cider-jack-in was invoked.
This is what I'm doing now, but it's a lot of change in a lot of places and feels wrong:
master...adrech:cider:fix-ssh-jack-in

Versions:
GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0)
CIDER 1.8.3-snapshot

@vemv
Copy link
Member

vemv commented Oct 18, 2023

Please create a new issue reflecting the same info / any other that the template suggests

@clojure-emacs clojure-emacs locked as resolved and limited conversation to collaborators Oct 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants