Fork me on GitHub
#calva
<
2023-09-25
>
Ingy döt Net15:09:02

I just noticed that with something like:

(do
  #_(prn 1)
      (prn 2)
  (prn 3)
)
pressing tab to reformat doesn't work. The #_ form prevents it for some reason.

pez19:09:34

I can’t reproduce this. Is there something else in your file that might make this happen?

Ingy döt Net20:09:59

Apparently because the exmaple I gave you works fine here 😕

Ingy döt Net20:09:01

Now I can't find it or repro

pez20:09:31

Too bad. Would be great with something minimal like what you posted, but with whatever it takes to repro. Next time! 😃

Ingy döt Net20:09:21

I'll be looking for it and next time I'll make sure it's reproducable

🙏 1
Thierry10:09:41

I've had this happen before, but only when using CTRL+ALT+L in VSCode. It only happens if you comment code using #_ { "key": "ctrl+alt+l", "command": "calva-fmt.alignCurrentForm", "when": "calva:keybindingsEnabled && editorTextFocus && !editorReadOnly && !hasOtherSuggestions && !suggestWidgetVisible && editorLangId == 'clojure'" } Heres the devtools error:

Kiyanosh Kamdar21:09:52

Hello, I think this may be an issue with Calva evaluating the file. See thread for more details…

Kiyanosh Kamdar21:09:41

Error:

; Execution error (NoSuchMethodError) at clj-yaml.core/make-yaml (core.clj:126).
; org.yaml.snakeyaml.representer.Representer: method <init>()V not found
Code that generates the error:
(defn ^:private load-yaml [fileName]
  (-> fileName
      (io/resource)
      (slurp)
      (yaml/parse-string)))

Kiyanosh Kamdar21:09:48

The (yaml/parse-string) generates the error I’m using latest clj-commons/clj-yaml {:mvn/version "1.0.27"}, Version 1.0.26 works fine. Runtime code works fine. Its just in my VSCode that I see the error

Kiyanosh Kamdar21:09:57

Commands that I run in Calva: ctrl + alt + c, ctrl + alt + j (this starts the repl) ctrl + alt + c, then click enter, to evaluate file.

Kiyanosh Kamdar21:09:16

:require [ :as io]
            [clj-yaml.core :as yaml]

Kiyanosh Kamdar21:09:44

Let me know if there is anything you need to reproduce.

pez21:09:13

What is meant with “Runtime code works fine”?

Kiyanosh Kamdar21:09:42

Our clojure main, runs in our kubernetes DEV environment without issues.

pez21:09:21

Does it load this file?

Kiyanosh Kamdar21:09:58

Yes. I believe so. Just switching versions to 1.0.26 works.

Kiyanosh Kamdar21:09:14

Here is a partial stacktrace:

clj-yaml.core/make-yaml (core.clj:126)
clj-yaml.core/make-yaml (core.clj:102)
clojure.core/apply (core.clj:667)
clojure.core/apply (core.clj:662)
clj-yaml.core/parse-string (core.clj:301)
clj-yaml.core/parse-string (core.clj:263)
viasat.sdp.api.smoketests.config/load-yaml (config.clj:13)

pez21:09:26

Can you load the file from the command line repl?

Kiyanosh Kamdar21:09:27

I’m not setup to do that locally, I can try it tomorrow. But because the runtime works, I feel like it should probably work too.

pez21:09:43

How can Calva evaluate the file if you can’t do it from the command line? (I’m not very familiar with kubernetes.)

Kiyanosh Kamdar21:09:37

Pez, if you can give me the steps, I’ll do it. I went straight to Calva in working with Clojure. And I’m working with existing functionality.

Kiyanosh Kamdar21:09:18

Anyways, I was just letting you know in case you want to look at it. I can use the old version for now.

pez21:09:23

Is it a Leiningen project?

Kiyanosh Kamdar21:09:32

no its a deps.edn.

Kiyanosh Kamdar21:09:01

Don’t worry about it man. We can look into it next time

Kiyanosh Kamdar21:09:34

I thought it would be super easy for you to try it out, but looks like it might be kind of tough

pez21:09:46

Haha, I am already worrying about it. 😃 Let’s figure out what we can figure out.

Kiyanosh Kamdar21:09:20

Without Calva, I’m useless. The command line is impossible.

pez21:09:04

Are you using Jack-in to start the repl?

pez21:09:53

What’s the jack-in command line? (Calva has a command for copying the jack-in command line to the clipboard).

Kiyanosh Kamdar21:09:29

I can make a short video of what I’m doing if that will help

pez21:09:39

I think I get what you are doing from the description above. (I had just managed to forget that you used jack-in.) The jack-in command line will show us how to start the repl ourselves.

Kiyanosh Kamdar21:09:19

Ok, I started it on the command line, let me try to connect to it from Calva

pez22:09:42

To try to isolate the problem we should get Calva out of the test first. As well as nrepl. So if you paste the jack-in command line here, I will try to edit a command line that will start an interactive repl prompt in the terminal.

Kiyanosh Kamdar22:09:10

clojure -Sdeps ‘{:deps {nrepl/nrepl {:mvn/version,“1.0.0”},cider/cider-nrepl {:mvn/version,“0.28.5"}}}’ -M -m nrepl.cmdline --middleware “[cider.nrepl/cider-middleware]”

Kiyanosh Kamdar22:09:15

; Starting Jack-in Terminal: pushd /Users/kkamdar/repos/sdp-api/app/smoketests ; clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" ; popd

pez22:09:39

Yes, that. You should be able to start a repl prompt just typing clj on the prompt.

Kiyanosh Kamdar22:09:30

i can do that, but I haven’t been able to figure out how to load the file.

Kiyanosh Kamdar22:09:40

Googling around, its not clear

pez22:09:34

=> (require 'the.ns.of.the.file)
Should do it.

Kiyanosh Kamdar22:09:58

did that, let me try it again. I also tried (load-file).

pez22:09:34

Yes, load-file is more like what Calva does.

Kiyanosh Kamdar22:09:34

kkamdar@C02G41SJML7L smoketests % clj
Clojure 1.11.1
user=> (requir(require 'viasat.sdp.api.smoketests.main)
nil
user=> (in-ns (in-ns viasat.sdp.api.smoketests.main)
Execution error (ClassCastException) at user/eval508 (REPL:1).
class java.lang.Class cannot be cast to class clojure.lang.Symbol (java.lang.Class is in module java.base of loader 'bootstrap'; clojure.lang.Symbol is in unnamed module of loader 'app')
user=>

Kiyanosh Kamdar22:09:41

let me try again using load-file

Kiyanosh Kamdar22:09:12

Clojure 1.11.1
user=> (load-f(load-file "src/main/clojure/viasat/sdp/api/smoketests/main.clj")
nil
user=> (in-ns (in-ns 'viasat.sdp.api.smoketests.main)
#object[clojure.lang.Namespace 0x5386cb4f "viasat.sdp.api.smoketests.main"]
viasat.sdp.api.smoketests.main=> (config/get-endpoints)           (config/get-endpoints)
Execution error (IllegalArgumentException) at viasat.sdp.api.smoketests.config/load-yaml (config.clj:12).
Cannot open <nil> as a Reader.
viasat.sdp.api.smoketests.main=>

pez22:09:26

What you pasted looks strange. Two nested in-ns.

Kiyanosh Kamdar22:09:44

i know. I think the output is just messed up

pez22:09:12

Yeah. but you are also missing the quote on the namespace. That’s what the error message is about.

Kiyanosh Kamdar22:09:14

same error:

Clojure 1.11.1
user=> (load-f(load-file "src/main/clojure/viasat/sdp/api/smoketests/main.clj")
nil
user=> (in-ns (in-ns 'viasat.sdp.api.smoketests.main)
#object[clojure.lang.Namespace 0x5386cb4f "viasat.sdp.api.smoketests.main"]
viasat.sdp.api.smoketests.main=>
viasat.sdp.api.smoketests.main=> (config/get-endpoints)           (config/get-endpoints)
Execution error (NoSuchMethodError) at clj-yaml.core/make-yaml (core.clj:126).
org.yaml.snakeyaml.representer.Representer: method <init>()V not found

Kiyanosh Kamdar22:09:05

But running it like this:

exec java $JAVA_OPTS \
    -Dfile.encoding=UTF-8 \
    -Dclojure.debug=false \
    -jar /app/smoketests-standalone.jar

Kiyanosh Kamdar22:09:13

works. So maybe its not related to Calva

pez22:09:44

Yeah, since you get the error without Calva, it means this is not caused by nrepl or Calva.

Kiyanosh Kamdar22:09:47

But related to clj. I can try upgrading to a later version

Kiyanosh Kamdar22:09:04

Ok, thanks Pez, sorry for being a pest. Let me try to update the version

pez22:09:23

It could also be related to the clj-yaml version. Check in #C042XAQFCCU if someone has an idea what could be going on.

Kiyanosh Kamdar22:09:49

oh ok, let me check there, didn’t know there was a channel for it

pez22:09:28

It’s natural to start asking here, especially since it works running the standalone jar.