Fork me on GitHub
#calva
<
2019-11-15
>
Marc O'Morain12:11:59

I’ve never manages to get Calva’s “Run Tests” to work - could someone help me debug what I’m doing wrong? I’m in a namespace that has 2 tests defined using clojure.test/deftest. And I run Calva Run Tests For Current Namespace:

Evaluating file: esxi_test.clj
=> #'circleci.vm-service.providers.esxi-test/it-handles-exceptions
Running namespace tests…

No tests found. 😱, ns: 0, vars: 0

Marc O'Morain12:11:44

Similarly, running all tests:

Running all project tests…

No tests found. 😱, ns: 0, vars: 0

Marc O'Morain12:11:02

I’m connected with leiningen / nREPL

pez12:11:11

I doubt you are doing something wrong, @marc-omorain. Rather what is Calva doing wrong here...

Marc O'Morain12:11:27

I wonder if I don’t have the correct Cider middleware.

pez12:11:08

Are you using jack-in or do you connect to a running repl?

Marc O'Morain12:11:46

“Connect to a running repl in the project” -> leiningen -> localhost -> it picks up the port automatically

Marc O'Morain12:11:12

So, this fails: (require 'cider.nrepl.middleware.test)

Marc O'Morain12:11:06

from when I was looking at reporting the tests to the test panel in VSCode before, I remember that there is an nrepl command to list the current installed middleware. It might be the case that I don’t have the required nrepl middleware loaded, and that we could detect that better by listing the middleware and ensuring that the required ones are loaded

pez12:11:43

Is there a reason you do not use jack-in?

Marc O'Morain12:11:16

I don’t know what jack-in is 🙂

pez12:11:18

Bring down the command palette. Type jack-in. The name is really something else, like Start the Project ... or some such.

Marc O'Morain12:11:19

my service is running in docker using docker-compose, and it exposes the nrepl port to localhost so that I can connect from VSCode. It looks like jack-in starts the project?

pez12:11:33

Exactly.

pez12:11:53

So seems there is a reason...

deas12:11:45

Trying out Calva. Im am jacked in, cursor is on a function in a .clj buffer. "Go to definition" says "No definition found for ...". Shouldn't that bring me to the definition of the function in the source?

pez12:11:24

@marc-omorain If you use jack-in to a local leiningen project, you will get the command line Calva would use to ensure it has the dependencies it needs.

pez12:11:55

@deas have you loaded the file?

deas12:11:35

@pez Just have the buffer open. Did not explicitely load it in the repl.

deas12:11:29

@pez Loading did the trick! Thanks.

pez12:11:08

Cool. We should try to hint that instead of showing no definition found...

pez12:11:11

We try to avoid loading code w/o the user's explicit action, b/c it can have quite severe effects. At the same time the dynamic way we find definitions demands that the code is loaded. Haha. But, to we can do better than just refuse to show definitions...

Marc O'Morain12:11:58

I’m running Calva in debug mode as described in the wiki, with the watcher running. If I change the Calva source code .ts files in the main VSCode Window, will the debug VSCode window load those changes? Or do I need to stop debugging and start debugging again to make the changes take effect?

pez12:11:11

Yeah, ts code do not hot-reload, unfortunately, that's only happening for the cljs code.

David Brear15:11:39

hey channel, if I let calva start the nrepl and then open up a cljs file the repl seems to only be looking for clj files. Has anyone seen an issue where cljs files are not even recognized?

pez18:11:20

I haven't seen that. How do you mean the repl only is looking for clj files?

David Brear19:11:26

so I am following these instructions: https://github.com/nrepl/piggieback#clojure-cli-aka-toolsdeps and it's starting an nrepl. In Calva, I go to "connect to a server in your project" and it fills in the port of the nrepl server but in the bottom next to the nREPL lightning bolt it only has clj

David Brear19:11:18

when I try to include a cljs file like lambda/core.cljs I do (require 'lambda.core) and it errors with could not find and files named lambda/core.clj

David Brear19:11:45

when I start the calva nrepl as well it does the same thing

pez19:11:02

Yeah. Calva only gives you a window into the the application, you’ll get the same errors. That is a good thing. 😃

pez19:11:16

To start with, I recommend you do not edit ~/.clojure/deps.edn, and instead let Calva start the project for you. It will then inject piggieback and such for you.

pez19:11:05

The command is *Calva: Start a Project REPL and connect*. See here: https://calva.readthedocs.io/en/latest/connect.html

pez19:11:54

Then it comes down to what kind of ClojureScript project you are trying with. You will need to know that when telling Calva to start the project. Calva supports Figwheel Main, shadow-cljs and lein-figwheel (which is called “Legacy Fighweel” in Calva to discourage using it).

pez19:11:39

If you are using Clojure CLI/tools.deps I recommend editing ~/.clojure/deps.edn like is described here: https://github.com/seancorfield/clj-new

David Brear19:11:44

oh actually now that you mention that there was a change recently to bring figwheel back in. I'll give that a shot. thanks in advance

pez19:11:42

If you are just trying things out I recommend the Figwheel Main template: https://rigsomelight.com/figwheel-main-template/

David Brear19:11:42

I think our issue is it is trying to start up a repl in the environment that i'm trying to connect to the nrepl in. I went back and tried with Clojure CLI + Figwheel Main and it's now just hanging on the "Jacking in..." phase

pez19:11:14

How long has it been hanging?

pez19:11:59

What do you have in the Jack-in Terminal?

pez19:11:57

If you have a REPL running from earlier tries you should probably kill that one first. Then jack-in from Calva.

David Brear19:11:58

so it looks like it started a repl in the terminal...

David Brear19:11:04

> Executing task: clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/cider-nrepl {:mvn/version "0.22.4"} cider/piggieback {:mvn/version "0.4.1"} com.bhauman/figwheel-main {:mvn/version "0.2.3"}}}' -A:dev <

2019-11-15 14:52:58.735:INFO::main: Logging initialized @4924ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Compiling build dev to "target/node/dev/dev-main.js"
[Figwheel] Successfully compiled build dev to "target/node/dev/dev-main.js" in 5.161 seconds.
[Figwheel] Watching paths: ("src") to compile build - dev
[Figwheel] Starting Server at 
[Figwheel] Starting REPL
Prompt will show when REPL connects to evaluation environment (i.e. Node)
Figwheel Main Controls:
          (figwheel.main/stop-builds id ...)  ;; stops Figwheel autobuilder for ids
          (figwheel.main/start-builds id ...) ;; starts autobuilder focused on ids
          (figwheel.main/reset)               ;; stops, cleans, reloads config, and starts autobuilder
          (figwheel.main/build-once id ...)   ;; builds source one time
          (figwheel.main/clean id ...)        ;; deletes compiled cljs target files
          (figwheel.main/status)              ;; displays current state of system
Figwheel REPL Controls:
          (figwheel.repl/conns)               ;; displays the current connections
          (figwheel.repl/focus session-name)  ;; choose which session name to focus on
In the cljs.user ns, controls can be called without ns ie. (conns) instead of (figwheel.repl/conns)
    Docs: (doc function-name-here)
    Exit: :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
[Rebel readline] Type :repl/help for online help info
Starting node ... 
Node output being logged to: target/node/dev/node.log
For a better development experience:
  1. Open  ... (in Chrome)
  2. Click "Open dedicated DevTools for Node"
ClojureScript 1.10.520
cljs.user=> 

David Brear19:11:48

in deps.edn we have this:

:dev {:extra-deps {com.bhauman/rebel-readline {:mvn/version "0.1.4"}}
                 :main-opts ["--main" "figwheel.main"  "-t" "node" "--build" "dev" "--repl"]}

pez19:11:59

I see. Maybe you choose the wrong alias. Let me try with a fresh template and I will be able to tell you what you should choose at the prompts.

pez19:11:59

OK. You shouldn’t use that profile then. Give me a sec, I’ll try myself here first so that I am not misleading you.

David Brear19:11:18

okay awesome, thanks so much

pez20:11:37

So start with no alias and with the dev profile.

David Brear20:11:39

I'm gonna run to a 1:1 with my manager but I'll b right back

pez20:11:39

Cool. Hope it will be a nice 1:1. 😃

pez20:11:37

When Calva asks which builds to start, choose booth dev and test. Then choose to connect to dev.

pez20:11:14

It’s all a bit confusing with profiles, aliases and builds…

David Brear20:11:26

so dev is a profile and we were just using it as an alias as well?

David Brear20:11:30

sorry about the delay

pez21:11:09

Maybe aliases on tools.deps can be thought of as equivalents to profiles in Leiningen projects…. An alias in tools.deps is sort of an alternative way to instrument the runtime environment. It often contains a main argument. … But I am the wrong person to answer this, because I haven’t fully wrapped my head around it. But in any case, that :dev entry you added to your deps.edn is an alias and using it makes Calva step back and not add it’s own main arguments, So that particular alias will not work with Calva.

pez21:11:52

Also. I think the correct sequence to use is to choose no alias, then choose to start the dev and test builds. Then choose to connect to dev.

David Brear21:11:06

so I went back and created a new figwheel-main project, should that just work right out of the box with Calva starting it up?

pez21:11:22

It’s getting late here, so I’ll be abandoning you now. I recommend asking in the channel. Others will probably step in. Also the #beginners channel is awesome.

pez21:11:13

Yes, the new project should work out of the box if you do not tell Calva to use any aliases.

David Brear21:11:20

oh okay no worries. Thank you again for all your help. I'm playing around with a new figwheel and this is making a lot of sense

David Brear21:11:38

yep, that works wonderfully

David Brear21:11:46

you rock bud, thanks so much!

pez21:11:56

Keep at it. Figwheel is awesome and you will be rewarded. 😃

pez21:11:07

And you are entirely welcome, sir!

pez20:11:42

Dear Calva friends: A new version of Calva is out, v2.0.61. See https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.61 for details, but most of it is about how Paredit behaves in the REPL window. We are sort of preparing for making the Paredit engine we use there be the Paredit engine we us in the editor as well. There are a couple of fixes to our Paredit and the Clojure parser bahind it still to do before we take that step.

calva 8