Fork me on GitHub
#calva
<
2018-11-16
>
pez09:11:48

Did Calva Paredit stop working for you guys with the latest vscode update?

slipset10:11:32

Hi, and thank you for Calva, I think it’s a very important contribution to the Clojure community!

slipset10:11:46

I’m a Emacs/Cider user, but would like to try it out.

slipset10:11:42

Problem is that when I installed VSCode and Calva, reloaded and tried to connnect, I get an error message saying command 'calva.connect' not found

slipset10:11:01

I’ve tried reinstalling both VSCode and calva a couple of times but with no luck.

slipset10:11:16

I’ve also deleted ~/.vscode inbetween reinstalls.

slipset10:11:38

Any other stuff I should try when reinstalling VSCode/calva?

slipset10:11:54

Like other directories which contain stale stuff?

slipset10:11:22

Does VSCode/calva log anywhere?

slipset10:11:57

started code with --verbose and get:

slipset10:11:01

[28607:1116/113614.837772:INFO:CONSOLE(294)] "%c[Extension Host] %cActivating extension 'cospaia.clojure4vscode' failed: Cannot read property 'document' of undefined. %c(at Object.showMessage (/Applications/Visual Studio ))", source: file:///Applications/Visual Studio  (294)
[28607:1116/113614.837887:INFO:CONSOLE(294)] "%c[Extension Host] %cActivating extension `cospaia.clojure4vscode` failed: ", source: file:///Applications/Visual Studio  (294)
[28607:1116/113614.838217:INFO:CONSOLE(294)] "%c[Extension Host] %cHere is the error stack: ", source: file:///Applications/Visual Studio  (294)
[28607:1116/113614.839856:INFO:CONSOLE(1445)] "%cTRACE", source: file:///Applications/Visual Studio  (1445)
[28607:1116/113614.840203:INFO:CONSOLE(3306)] "Activating extension 'cospaia.clojure4vscode' failed: Cannot read property 'document' of undefined.", source: file:///Applications/Visual Studio  (3306)

slipset10:11:26

Seems like I forgot to remove stuff from ~/Library I’ve done that now and try a fresh reinstall.

pez10:11:37

Hello, @slipset, I am sorry about that problem, I am trying to figure out how to fix it, it is probably some really stupid mistake of mine somewhere. Anyway, Calva fails to activate if there are no clojure-ish files opened. So, closing Code with a clojure file open and then reopen the same folder should make it work.

slipset10:11:05

Ok, I’ll try a reinstall and stuff and see what happens.

pez10:11:21

I don't think you need reinstalling anything.

slipset10:11:08

Oh, I do, I just removed everything 🙂

pez10:11:49

Haha, oh, I really must fix this bug!

slipset10:11:00

It might just be me though.

pez10:11:59

No, it isn't. I think it makes lots of people just give up on Calva, and never tell me it failed them.

slipset10:11:52

Yeah, those are the worst kind of customers 🙂

slipset10:11:49

So. Removed ~/.vscode, ~/Library/Application Support/Code, and /Applications/Visual Studio

slipset10:11:07

Downloaded a fresh VSCode, moved it to Applications

slipset10:11:27

started it, installed the three calva things, pressed reload.

slipset10:11:00

Opened a clojure file, pressed command-shift-p wrote calva-connect

slipset10:11:06

and getting the error.

pez10:11:08

You should only need to install one Calva thing. Calva.

pez10:11:32

But that is of no consequence to the error.

slipset10:11:38

Yeah, I only installed calva, but got the two other calva things automagically.

slipset10:11:59

Should I just file an issue on Github?

pez10:11:03

Is there a clojure file opened when you start up code?

slipset10:11:24

When I started code now, there was no clojure file open.

slipset10:11:42

But I opened up a clojure file before trying to connect

pez10:11:44

Then Calva fails. That is the bug.

pez10:11:17

close code leaving a clojure file opened and then open code again.

slipset10:11:06

Hmm, every time I close code, it starts up in a blank state?

pez10:11:41

The best way is to installl code commandline command and then start code from the project folder in the terminal with code something.clj .

slipset10:11:42

I got it now

slipset10:11:09

If I open Code, choose Open recent, and then calva connect, it works.

pez10:11:47

Yeah, that should work too. I'll add it to my tips for workarounds until I have sorted the bug out.

slipset10:11:58

Cool.. Thanks for the help

pez10:11:07

no problem!

slipset10:11:27

My plan is to try to use calva a bit to see if how it performs compared to Cider

pez10:11:47

Now let's see if you get the dependencies right. Next Calva hurdle...

slipset10:11:08

I used a slight trick there, you see 🙂

slipset10:11:20

I connected to a repl that was started by Cider 🙂

pez10:11:41

It is inspired by Cider, but I am not really capable of competing with it. 😃

slipset10:11:47

So it should have all hte deps set up correctly

pez10:11:23

I should add the jack in to Calva, same way as Cider.

slipset10:11:05

Yeah, and the “hook up out and errr” thingy. That’s super important.

slipset10:11:25

More important than jack-in IMO

pez10:11:56

Interesting. Doesn't (println) cover some of that?

slipset10:11:32

I dont’ think it does. Did you see @bozhidar’s comment on the Github issue?

pez11:11:27

Actually, some of that hooking of err should be handled by adding jack-in. Then at least one of the terminal REPLs will have it hooked up to start with. (And since Calva does not support opening multiple REPLs yet…)

Marc O'Morain13:11:49

@pez from the code, it looks to me like Calva makes a fresh nrepl connection each time you run a command? Is that the case – I wonder if this could be leaking some sockets or file descriptors of something causing the problems with opening new tabs that some of us have periocially

pez14:11:28

@marc-omorain Yes, it does. The current connection does not implement the message ID so can only really handle one message -> response at a time and thus it behaves stupidly like that. I don't think it leaks sockets, but it can be doing that anyway of course.

adam15:11:01

Hi all. I am using Calva but the go to definition feature is not working. I am new to Clojure so I might be missing something... I generated the project using lein new compojure. Any idea what do I need to do to get it to work?

Marc O'Morain15:11:15

I’m getting some strange comments indenting over the last few days with Calva.

Marc O'Morain15:11:41

When I press enter, comments move one indent to the right.

pez17:11:43

@marc-omorain please file an issue about it. I suspect it has something to do with cljfmt. (Since that is what I am using for the indenting and I can’t think of anything I do with the results that cljfmt provides that would abuse comments like that.

pez17:11:30

@somedude314 It is probably a dependency issue. See if you get it working with a project generated with lein new reagent, which has the dependencies needed by Calva in place. (To confirm it is a dependency issue, that is. We can help you get the dependencies right if that indeed is the issue.)

adam17:11:15

Thanks @pez. I will do that and report back.

pez17:11:14

(And I really should make Calva able to help with injecting what it needs to function.)

adam18:11:57

@pez: it works on the template you provided. I guess I will have to try to mimic the setup...

pez18:11:29

@somedude314 Since you are using Leinigen, one way is to request the dependencies in your ~/.lein/profiles.clj. If the contents of that file looks like this:

{:repl {:plugins [[cider/cider-nrepl "0.18.0-SNAPSHOT"]]
        :dependencies [[nrepl "0.4.5"]
                       [cider/piggieback "0.3.9"]
                       [figwheel-sidecar "0.5.16"]]
        :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}}
… you should be set. (I am not sure if this will override the settings in the Compojure template, so I am curious about if it helps.)

adam18:11:11

@pez: I am getting this error: when placing the bit you sent in ~/.lein/profiles.clj:

> lein repl
Retrieving cider/cider-nrepl/0.18.0-SNAPSHOT/cider-nrepl-0.18.0-20180804.114958-23.pom from clojars
Retrieving cider/cider-nrepl/0.18.0-SNAPSHOT/cider-nrepl-0.18.0-20180804.114958-23.jar from clojars
Retrieving cider/piggieback/0.3.9/piggieback-0.3.9.pom from clojars
Retrieving figwheel-sidecar/figwheel-sidecar/0.5.16/figwheel-sidecar-0.5.16.pom from clojars
Retrieving figwheel/figwheel/0.5.16/figwheel-0.5.16.pom from clojars
Retrieving com/google/javascript/closure-compiler-externs/v20170910/closure-compiler-externs-v20170910.jar from central
Retrieving args4j/args4j/2.33/args4j-2.33.jar from central
Retrieving org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar from central
Retrieving com/google/javascript/closure-compiler-unshaded/v20170910/closure-compiler-unshaded-v20170910.jar from central
Retrieving com/google/guava/guava/20.0/guava-20.0.jar from central
Retrieving org/clojure/tools.reader/1.1.0/tools.reader-1.1.0.jar from central
Retrieving figwheel/figwheel/0.5.16/figwheel-0.5.16.jar from clojars
Retrieving cider/piggieback/0.3.9/piggieback-0.3.9.jar from clojars
Retrieving figwheel-sidecar/figwheel-sidecar/0.5.16/figwheel-sidecar-0.5.16.jar from clojars
Error loading cider.piggieback: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(cljs/util.cljc:1:1)
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: cider.piggieback/wrap-cljs-repl in this context, compiling:(/private/var/folders/4n/mzsddrms1jj46yygfxxwk8bw0000gn/T/form-init16575676911808956555.clj:1:8233)
By the way, I am not using ClojureScript.

adam18:11:11

@pez: I am getting this error: when placing the bit you sent in ~/.lein/profiles.clj:

> lein repl
Retrieving cider/cider-nrepl/0.18.0-SNAPSHOT/cider-nrepl-0.18.0-20180804.114958-23.pom from clojars
Retrieving cider/cider-nrepl/0.18.0-SNAPSHOT/cider-nrepl-0.18.0-20180804.114958-23.jar from clojars
Retrieving cider/piggieback/0.3.9/piggieback-0.3.9.pom from clojars
Retrieving figwheel-sidecar/figwheel-sidecar/0.5.16/figwheel-sidecar-0.5.16.pom from clojars
Retrieving figwheel/figwheel/0.5.16/figwheel-0.5.16.pom from clojars
Retrieving com/google/javascript/closure-compiler-externs/v20170910/closure-compiler-externs-v20170910.jar from central
Retrieving args4j/args4j/2.33/args4j-2.33.jar from central
Retrieving org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar from central
Retrieving com/google/javascript/closure-compiler-unshaded/v20170910/closure-compiler-unshaded-v20170910.jar from central
Retrieving com/google/guava/guava/20.0/guava-20.0.jar from central
Retrieving org/clojure/tools.reader/1.1.0/tools.reader-1.1.0.jar from central
Retrieving figwheel/figwheel/0.5.16/figwheel-0.5.16.jar from clojars
Retrieving cider/piggieback/0.3.9/piggieback-0.3.9.jar from clojars
Retrieving figwheel-sidecar/figwheel-sidecar/0.5.16/figwheel-sidecar-0.5.16.jar from clojars
Error loading cider.piggieback: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(cljs/util.cljc:1:1)
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: cider.piggieback/wrap-cljs-repl in this context, compiling:(/private/var/folders/4n/mzsddrms1jj46yygfxxwk8bw0000gn/T/form-init16575676911808956555.clj:1:8233)
By the way, I am not using ClojureScript.

pez18:11:32

Try only this in profiles.clj:

{:repl {:plugins [[cider/cider-nrepl "0.18.0"]]
        :dependencies [[nrepl "0.4.5"]]}}

adam18:11:21

@pez: No luck:

> lein repl
nREPL server started on port 51545 on host 127.0.0.1 - 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by cider.inlined_deps.orchard.v0v3v0.dynapath.v0v2v5.dynapath.defaults$eval3795$fn__3796 to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of cider.inlined_deps.orchard.v0v3v0.dynapath.v0v2v5.dynapath.defaults$eval3795$fn__3796
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.9.0
Java HotSpot(TM) 64-Bit Server VM 11.0.1+13-LTS
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=>

practicalli-john20:11:45

@somedude314 this is a known reflection bug you get when running some Clojure on Java 11. Try this with Java 8, either OpenJDK or Oracle Java and the error will go away.

❤️ 4
adam20:11:24

Gotcha, thanks

adam18:11:21

@pez: No luck:

> lein repl
nREPL server started on port 51545 on host 127.0.0.1 - 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by cider.inlined_deps.orchard.v0v3v0.dynapath.v0v2v5.dynapath.defaults$eval3795$fn__3796 to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of cider.inlined_deps.orchard.v0v3v0.dynapath.v0v2v5.dynapath.defaults$eval3795$fn__3796
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.9.0
Java HotSpot(TM) 64-Bit Server VM 11.0.1+13-LTS
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=>

pez19:11:02

I’ll try tis out myself, @somedude314

pez20:11:43

Alright, so really strange. For me it works with no errors using a project generated by lein new compojure

adam20:11:58

@pez: How does your ~/.lein/profiles.clj look right now? You provided two versions so I am wondering which one is working.

pez20:11:47

Sorry for the radio silence, I am trying to figure out what is going on. The project created for me does not have any compojure stuff included. In fact this is the entire project.clj:

`
(defproject compojure "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[org.clojure/clojure "1.8.0"]])

pez20:11:08

Is that what your project.clj looks like too?

adam20:11:35

@pez - no rush. I generated the project using "lein new compojure myproject". The content of project.clj is:

(defproject myproject "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [compojure "1.6.1"]
                 [ring/ring-defaults "0.3.2"]]
  :plugins [[lein-ring "0.12.4"]]
  :ring {:handler myproject.handler/app}
  :profiles
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}})

pez20:11:50

Yeah, stupid me, I now generated my project the same way. Getting the same project.clj. However, no errors reported on startup and Calva works.

pez20:11:08

What happens if you empty the contents of your lein profiles file?

pez20:11:18

(I get a complaint about that the file cannot be empty, but things work anyway.)

adam20:11:04

@pez: If I empty ~/.lein/profiles.clj, I get File cannot be empty. I will try deleting it.

pez20:11:41

I get that too. But things still work.

adam20:11:29

Still not working but lein new reagent myproject works fine 😕

pez20:11:39

It is madness!

adam20:11:22

In any case, thanks so much for the help. I will try different templates later on or try to copy parts of the working one until I get it.

pez20:11:25

This project.clj works for me:

(defproject comp "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [compojure "1.6.1"]
                 [nrepl "0.4.5"]
                 [ring/ring-defaults "0.3.2"]]
  :plugins [[lein-ring "0.12.4"]
            [cider/cider-nrepl "0.18.0"]]
  :ring {:handler comp.handler/app}
  :profiles
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}})

pez20:11:50

But , of course, it works for me a bit no matter what I try. Haha.

pez20:11:54

I’m hitting the sack here. I’d like to continue figuring this out tomorrow, if we manage to have some time both of us. It shouldn’t be this hard to get going with Clojure and I want to Calva to help more than it hurts the process.

👍 4
practicalli-john20:11:45

@somedude314 this is a known reflection bug you get when running some Clojure on Java 11. Try this with Java 8, either OpenJDK or Oracle Java and the error will go away.

❤️ 4