Fork me on GitHub
#cider
<
2017-11-20
>
13tales04:11:00

Hey there; I’m a Clojure newbie doing some http://Exercism.io 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.

grzm05:11:07

Have you required the namespace?

grzm05:11:02

I'd do something like

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

jumar05:11:46

@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)

13tales05:11:10

@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 🙂

13tales05:11:46

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

grzm05:11:28

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

iperdomo11:11:14

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

iperdomo11:11:08

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

iperdomo11:11:20

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

iperdomo11:11:28

(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]}

iperdomo11:11:36

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

iperdomo11:11:14

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

iperdomo11:11:36

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

dominicm11:11:38

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

dominicm11:11:00

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.

iperdomo11:11:02

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

iperdomo11:11:29

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

iperdomo11:11:50

@dominicm thanks will try this out

iperdomo12:11:52

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

gonewest81816:11:14

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.