Fork me on GitHub

Hey there; I’m a Clojure newbie doing some problems in Spacemacs. Does anyone have any advice on getting the Cider REPL to work for these exercises? I can’t seem to get the REPL to use the right namespace; I get “undefined” errors when trying to run my functions.


Have you required the namespace?


I'd do something like

(require '[ :as ns])
(ns/my-func ,,,)


@thomas.armstrong depending on your workflow you can also use cider-repl-set-ns (C-c M-n) to set the REPL namespace to the namespace of the current buffer. I usually work only in namespace buffer (the actual file with code) and eval either the whole buffer or expressions one by one. That way, it should always work. Sometimes, I want to send expression to the REPL (for better "visualization" of result) - then I need to make sure that REPL has proper namespace (C-c M-n) and just call cider-send-last-sexp-to-repl (`,s e` using Spacemacs in evil mode)


@grzm Hey, thanks for getting back to me. I tried that, and it works. Was hoping to get it to work without needing to require the ns first, but whatever works 🙂


@jumar Yes, I had found that command; not sure what I was doing wrong before, but it seems to work now. Thanks, though!


@thomas.armstrong No problem. require loads the file. Code isn't automatically loaded at the repl.


there is a container with the Clojure code and an nREPL server running, I can connect from my host machine using cider-connect


and everything seems to work except Jump to definition: Meta + .


all the vars have relative file path, e.g.


(meta #'akvo.lumen.lib.collection/all) {:arglists ([tenant-conn]), :line 5, :column 1, :file "akvo/lumen/lib/collection.clj", :name all, :ns #namespace[akvo.lumen.lib.collection]}


when i try to jump to that definition collection/all i get .. No source location


if i evaluate the file(Ctrl + c , Ctrl + k), the vars get redefined, the metadata gets changed to absolute paths and the jump to definition works again


is this considered a bug? can i workaround this issue without evaluating the target namespace ?


@iperdomo I think cider resolves the metadata to an absolute path for you, but that absolute path is the one inside the docker container.


Someone once told me there was a trick to have emacs rewrite the path using some built-in emacs feature (maybe tramp?) but I don't know what it is.


hey @dominicm ... I've been reading about tramp but it feels that i'm adding more complexity to the whole thing


if there is a trick to rewrite the path would be really nice


@dominicm thanks will try this out


docker-tramp seems to work ... it feels slower though


What about mounting the source dir in the docker container using the same absolute path that occurs on the outside? You’d have to customize the docker-compose.yml per developer, or possibly use environment variable substitution to generalize it.