Fork me on GitHub
#vim
<
2019-06-17
>
credulous16:06:57

Hi. I’m having some trouble getting my workflow going with a project I started using CLI and deps.edn. I can’t eval from vim for some reason. When I try to eval the (ns) function in any of my source files I get an error:

Execution error (FileNotFoundException) at user/eval31498 (REPL:1).
Could not locate alexandria/templates__init.class, alexandria/templates.clj or alexandria/templates.cljc on classpath.

credulous16:06:22

My deps.edn looks like

{:aliases { :run {:main-opts [ "-m" "alexandria.core" ] } }

 :paths ["src/clj" "resources" ]

 :deps {
... various dependencies
}
 }

credulous16:06:16

I have a source file src/clj/user.clj … within that file I can eval the (ns) function as well as any random thing I write, e.g. (+ 1 2)

credulous16:06:50

But when I go to src/clj/alexandria/templates.clj as in the example above, I get a classpath error.

credulous16:06:20

From the actual repl window, I can (require 'alexandria.templates) without any problem, so the kind folks in #beginners suggested I ask here as it seems to have to do with fireplace.

dave16:06:24

I think the issue there is probably that the "clj" CLI tool doesn't start an nREPL out of the box

dave16:06:36

Fireplace needs an nREPL to connect to

dave16:06:54

I think you have to do something like this: https://stackoverflow.com/a/54066339

credulous17:06:00

Thanks for the pointer… but if that’s the case, why can I eval code from the src/clj/user.clj file with no problem?

dave17:06:32

Ah, OK, so you probably have a different problem

credulous17:06:12

Nonetheless… when I run clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.5.3"}}}' -m nrepl.cmdline from the command line as suggested in your link, everything works

credulous17:06:20

so thank you! but I wish I understood

dave17:06:44

I think maybe the problem is a mismatch between the filename and the namespace name in the ns form

credulous17:06:47

I can run that repl as above then start the server through the repl

credulous17:06:36

In the original case, typing (require 'alexandria.templates) at the repl worked though.. so I don’t think it’s a filename mismatch

credulous17:06:48

it was only in the editor that it choked

dave17:06:57

e.g. I think your user.clj needs to start with "(ns user)"

credulous17:06:43

Yes, user.clj does start with (ns user), and it works fine… I can evaluate in the editor through fireplace

credulous17:06:07

it was only my “real” source files that didn’t work

dave17:06:47

Ah, OK. I was misreading

dave17:06:24

Something to check: what port is fireplace connected to?

dave17:06:09

You can explicitly connect to the port of your nREPL (let's say 12345) by running ":Connect 12345"

dave17:06:04

If you run ":Connect" without the port it should connect to the port in ./.nrepl-port (placed there by NREPL) in the current directory