Fork me on GitHub
#calva
<
2023-09-19
>
zimablue16:09:58

I'm developing an electron app with calva, but somehow println output has stopped showing up in the output.calva.repl, repl is working great, eg. evalling :hello or (+ 1 1) shows in the output, but (println "hello") doesn't and it used to?

pez16:09:49

Are you using shadow-cljs for that app? Can you enable the nrepl message log (there’s a Calva command for that) and see if the messages are there? Do you know when it used to do this?

zimablue16:09:31

I'm wondering if I've just toggled a setting but I don't know which if so

pez16:09:25

We added a setting a while ago for redirecting output to the REPL window. It should have nothing to do with this behaviour, but disabling that will restore the old behaviour (after restart of the REPL). You could try it just so that we can rule out that change as the culprit.

zimablue16:09:26

this is the result of a println hello call with the logging enabled:

zimablue16:09:27

<- received { id: '95', ns: 'tab-backend.test.from-excel', session: '49ba1773-57a3-4bed-a739-2656fd0fa6a1', value: 'nil' } <- received { id: '95', session: '49ba1773-57a3-4bed-a739-2656fd0fa6a1', status: [ 'done' ] }

zimablue16:09:55

when I do it again it's different, maybe I messed the first one:

op: 'eval',
  session: '49ba1773-57a3-4bed-a739-2656fd0fa6a1',
  code: '(println "hello")',
  'nrepl.middleware.print/options': { 'right-margin': 120, length: 50 },
  'nrepl.middleware.print/print': 'cider.nrepl.pprint/pprint',
  file: '/home/zimablue/projects/kangrok-core/src_clj/tab_backend/test/from_excel.cljc',
  line: 643,
  column: 4,
  stdout: [Function: stdout],
  stderr: [Function: stderr],
  pprint: true
}

<- received
{
  id: '96',
  'nrepl.middleware.print/error': "Couldn't resolve var cider.nrepl.pprint/pprint",
  session: '49ba1773-57a3-4bed-a739-2656fd0fa6a1',
  status: [ 'nrepl.middleware.print/error' ]
}

<- received
{
  id: '96',
  ns: 'tab-backend.test.from-excel',
  session: '49ba1773-57a3-4bed-a739-2656fd0fa6a1',
  value: 'nil'
}

<- received
{
  id: '96',
  session: '49ba1773-57a3-4bed-a739-2656fd0fa6a1',
  status: [ 'done' ]
}

zimablue16:09:16

it's unhappy about pprint but I'm not calling pprint

zimablue16:09:07

if I toggle "enable pprint for all evaluations" the error in the nrepl log goes away but I still don't get println output in the output.calva.repl window

zimablue16:09:18

I'm not going mad, it's intended to show up there right?

pez16:09:39

Ah, good spottijng. nrepl is calling pprint. You could… no, you tried that.

pez16:09:51

I’m actually not sure what to expect. ClojureScript pprint is a bit special. Let me see how it behaves for me.

pez16:09:56

I get it printed as you expect when trying with Calva itself. Which is not exactly an Electron app, but I think it is a good proxy.

pez16:09:03

We’re using shadow-cljs for Calva and building a :node-library.

pez16:09:46

Do you see hello printed in the dev console?

zimablue16:09:32

by dev console, you mean the bottom terminal output window where the app is running?

pez16:09:50

This is what I get in the nrepl message log

-> sent
{
  id: '504',
  op: 'eval',
  session: '2d0bbf0e-d288-446c-beb8-1e71793779d7',
  code: '(println "hello")',
  'nrepl.middleware.print/options': { 'right-margin': 120, length: 50 },
  'nrepl.middleware.print/print': 'cider.nrepl.pprint/pprint',
  file: '/Users/pez/Projects/calva/.calva/output-window/output.calva-repl',
  line: 139,
  column: 1,
  stdout: [Function: stdout],
  stderr: [Function: stderr],
  pprint: true
}

<- received
{
  id: '504',
  out: 'hello',
  session: '2d0bbf0e-d288-446c-beb8-1e71793779d7'
}

<- received
{
  id: '504',
  out: '\n',
  session: '2d0bbf0e-d288-446c-beb8-1e71793779d7'
}

<- received
{
  id: '504',
  ns: 'calva.fmt.formatter',
  session: '2d0bbf0e-d288-446c-beb8-1e71793779d7',
  value: 'nil'
}

<- received
{
  id: '504',
  session: '2d0bbf0e-d288-446c-beb8-1e71793779d7',
  status: [ 'done' ]
}

<- received
{
  'changed-namespaces': {},
  id: '504',
  'repl-type': 'cljs',
  session: '2d0bbf0e-d288-446c-beb8-1e71793779d7',
  status: [ 'state' ]
}
Just adding it here for anyone who might be able to make sense of this problem.

bortexz17:09:27

Not sure if this should go here or #clj-kondo, but posting it here for now as I encounter this with Calva (but not running clj-kondo cli). It seems that clj-kondo stops reporting errors inside a try block, when calling fn's on a different namespace, but if the same fn call is used outside of the try, then both the one outside and the one inside are reported. More in 🧵

bortexz17:09:52

(afn is a fn of 2 arguments)

pez17:09:44

Looks wrong to me. I’d reproduce that using the cli and report it in #CHY97NXE2

bortexz17:09:59

When using cli, clj-kondo correctly reports it:

src/b.clj:6:8: error: a/afn is called with 1 arg but expects 2
linting took 42ms, errors: 1, warnings: 0

bortexz17:09:34

with the output above, can't see the error on the editor

pez18:09:30

That’s interesting. I can reproduce it.

pez18:09:27

Even using it via clojure-lsp reports the error:

~/Projects/calva/clojure-lsp diagnostics
[ 99%] Project analyzed            Finding diagnostics...
src/b.clj:4:7: info: [clojure-lsp/unused-public-var] Unused public var 'b/bfn'
src/b.clj:6:8: error: [invalid-arity] a/afn is called with 1 arg but expects 2

pez18:09:42

But it is not reported as a problem in Calva/VS Code:

pez18:09:46

Do you understand what could be going on, @UKFSJSM38?

pez18:09:54

Calling it from (finally) also wakes the reporting up.

👍 1
bortexz11:09:13

Just observed something weird on the original project where I saw this (not the reproduction repo), the error appeared on the file tree (marked 1 error next to filename), then clicked the file, the error showed below the fn call, and then it disappeared (might have saved the file)

bortexz11:09:52

Haven't been able to reproduce on the small repro project yet, but on my original project, I am observing that when I reload vscode window without having the affected file on the editor, then the error reappears. When I go to the file, it disappears. At some point, it kept displaying the error until I saved the file, but on further tries to repro, the error disappeared as soon as I opened the file in the editor

ericdallo12:09:57

that's weird, I can't repro that, maybe some edge case bug in clj-kondo, but we'd need a repro which can consistently or pretty close to that to understand the root cause

breno1232119:09:07

Hie! I'm trying to use the Calva TestExplorer and wanted to know if its possible when I run the test to https://calva.io/test-runner/#vs-code-test-ui? Even if possible to write an hook function that automagically does this in calva 👀 I'm getting No tests found 😢

pez06:09:01

There’s no hook for it, and I am unsure if there’s API for that in VS Code. You can create a custom repl command that loads your test namespaces. https://calva.io/custom-commands/ And there’s calva.autoEvaluateCode.onConnect https://calva.io/customizing-jack-in-and-connect/ where you can load things on connection of the repl. (If someone finds a VS Code API for a pre-tests hook, I’d love to know.)

nice 1
gratitude 1
breno1232117:09:09

Also One question @U0ETXRFEW when I load a namespace it load all the tree bellow? I don't recall :thinking_face:

pez18:09:15

Yes, you only need to evaluate some top level namespace. And then any namespace you change.

gratitude 1