Fork me on GitHub
#calva
<
2019-10-09
>
mattly04:10:57

Parinfer fix?

pez05:10:26

It turned out you couldn't completely stop Calva from formatting-as-you-type. But now you can. So Parinfer can do its job, I can't do much about the job Parinfer does though, so I certainly prefer Calva's formatting.

macgyver14:10:03

cross-post because I was just referred to this channel! Hey all, new to clojure, coming from node 👋. I am trying to use vscode with some goodies (autocompletion, linting, etc.) and then run that file with repl. On each save, re-run this file. This way I get quick feedback loop and can work in familiar environment instead of in terminal. Does this make sense? If not, what are some alternative methods?

pez14:10:22

@adamfranzen: cross-posting is fine! 😃

pez14:10:18

You can certainly rerun the file on each save. However, I suggest you utilize the power of the Clojure REPL and rather rerun the pieces of code you have changed, in a highly incremental fashion. I try to describe my own way of coding here: https://clojureverse.org/t/why-clojure-by-uncle-bob/4751/5?u=pez

macgyver14:10:54

ok, so I am following Something To Try First from the readme. I have a new directory. I created project.clj. I wrote a function and then run ctrl+alt+c e and it says Command Calva: Evaluate Current Form is not enabled int he current context. How do I enable this?

pez14:10:27

First you'll need to read the section above Something to try first 😃 https://github.com/BetterThanTomorrow/calva#how-to-connect-calva-to-your-project

pez14:10:09

So, Calva needs to be connected to your running Clojure application in order to help with evaluations. The easiest way to do it is to let Calva start the app for you. (Search for Jack in in the command palette).

macgyver14:10:23

ok, so when it says to open a project, should I create a new project with leiningen?

macgyver14:10:39

or can I just evaluate a single .clj file?

pez14:10:56

Open the directory where you have your project.clj.

pez14:10:01

Then Jack in.

pez14:10:27

And, yes, it might be best to create a new project using lein. @brandon.ringe wrote a great short guide for how to get started with Clojure. Let me find it for you.

calva 4
macgyver14:10:45

🙌 thank you!

macgyver14:10:06

that gist seems to be perfect. I am running into this issue that seems to not be working like the guide describes. I open the new lein project in code. I open core.clj and run ctrl+alt+c, ctrl+alt+j and the terminal appears. Calva appears to be doing it's thing, but then it says Jacking in... Hooking up nREPL sessions... and then it hangs there. Can you help me please?

pez14:10:25

I'm afk right now. I hope someone else here can help until I'm back with a computer.

macgyver14:10:05

So I do not need to run lein repl, correct? I am assuming that calva takes care of starting the repl?

pez14:10:43

Yeah. So it does that in the integrated terminal. Paste the contents from there here, please. Maybe we can see what is (not) going on.

macgyver14:10:57

OK, so I got one step further. Instead of selecting Leiningen, I selected Leiningen + shadow-clsj and it is working. Not sure why :man-shrugging:

pez14:10:38

That is totally weird.

macgyver14:10:38

The project I created was created with lein new project-clojure, so I would have thought the Leiningen option would have been correct. Got a repl working though!

macgyver14:10:20

I will say that I hacked quite a bit trying to get this working in the past, with lein, and other vscode extensions (which are not removed or disabled), so I fully believe the problem is on my end

pez14:10:27

The Leiningen option should be the one working.

pez14:10:17

But, disabling ask other clojure related extensions should at least be safer. Clojure Lint can be kept, unless you're on Windows.

macgyver14:10:52

I am on fedora

pez15:10:29

Cool. I hope someone here, using Linux can test the fresh Leiningen jack in.

macgyver15:10:56

where can you define which port to connect to for lein?

Dmytro Bunin15:10:43

there is another command

Dmytro Bunin15:10:45

calva connect I think

macgyver15:10:03

ok, so getting nREPL to connect using leiningen + shadow-clsj was one of solution. Here is the error log:

> Executing task: lein update-in :dependencies conj '[nrepl"0.6.0"]' -- update-in :plugins conj '[cider/cider-nrepl"0.22.1"]' -- update-in '[:repl-options :nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' -- repl :headless <

Warning: implicit middleware found: cider-nrepl.plugin/middleware 
Please declare all middleware in :middleware as implicit loading is deprecated.
nREPL server started on port 40403 on host 127.0.0.1 - 
ERROR: Unhandled REPL handler exception processing message {:op eval, :code *ns*, :id 1}
java.io.FileNotFoundException: /usr/lib/jvm/java-1.8.0-openjdk-...

macgyver15:10:15

Leiningen 2.8.3 on Java 1.8.0_222 OpenJDK 64-Bit Server VM

Dmytro Bunin15:10:58

do you have anything in your ~/.lein/profiles.clj ?

Dmytro Bunin15:10:24

no that can’t be it

macgyver15:10:56

no, that file doesn't exist

Dmytro Bunin15:10:14

can you try to connect without shadow-cljs?

macgyver15:10:49

it doesn't work with leiningen either

macgyver15:10:59

that log was from trying to connect with leiningen actually

Dmytro Bunin15:10:10

java.io.FileNotFoundException: /usr/lib/jvm/java-1.8.0-openjdk-

Dmytro Bunin15:10:16

I guess there is no java?

macgyver15:10:27

wait, what?

macgyver15:10:44

lein -v gives me Leiningen 2.8.3 on Java 1.8.0_222 OpenJDK 64-Bit Server VM

Dmytro Bunin15:10:25

does the which java give you /usr/lib/jvm/java-1.8.0
.

macgyver15:10:52

it only gives me /usr/bin/java

Dmytro Bunin15:10:36

might be related

Dmytro Bunin15:10:24

that’s ancient though

Dmytro Bunin15:10:27

I have no idea 😉

pez15:10:40

Or at least the JAVA_HOME or some such is pointing wrong.

macgyver15:10:45

I am reinstalling openjdk

pez15:10:12

I use sdk-man, and love it.

macgyver15:10:31

huh, alright. why do you like it?

pez15:10:27

I'm right now trying to understand how the REPL server can start and then later a complaint about no java....

macgyver15:10:47

same...very confusing

pez15:10:27

sdk-man because I am involved in different project demanding different java versions. And skd-man lets me download and switch between java versions at will.

pez15:10:28

Which version of Leiningen are you using?

pez15:10:53

OK. You've already answered that.

macgyver15:10:50

sorry for the headache...am excited to learn clojure though!

pez15:10:16

I'm usining 2.9.1. Maybe you have better luck using that.

pez15:10:43

Where's $JAVA_HOME pointing at?

pez15:10:31

Don't worry about headache. I always learn something new with each new strange problem. 😃

pez15:10:53

And Clojure is amazing. Worth quite a lot of trouble, I'd say.

macgyver15:10:57

how do I see where $JAVA_HOME is pointing?

macgyver15:10:18

typing it into terminal returns nothing

pez15:10:21

echo $JAVA_HOME

macgyver15:10:40

it is literally blank

pez15:10:39

Consider giving sdk-man a try. It sets up java properly. 😃

pez15:10:07

And it has the most awesome logo.

macgyver15:10:31

ok, I installed it and ran echo $JAVA_HOME and it is still blank

macgyver15:10:53

n/m I am not done installing

macgyver15:10:03

yup, still blank

dominicm15:10:08

You'll have to start a new terminal, if you haven't

macgyver16:10:04

still blank

macgyver16:10:54

I see pages for how to set JAVA_HOME, I am just not positive where to set it to

macgyver16:10:42

I just tried setting all of this up in a VM and it worked perfectly

macgyver16:10:52

so...how to troubleshoot my machine

macgyver16:10:33

interestingly enough, in the VM, echo $JAVA_HOME is blank as well

macgyver16:10:40

the VM is fedora as well

Dmytro Bunin16:10:19

It’s also empty for me 🙂

macgyver16:10:53

how can I see the location where the command lein is associated with?

macgyver16:10:13

it isn't in ~/bin

macgyver16:10:40

running lein upgrade

macgyver16:10:03

Leiningen 2.9.1 on Java 1.8.0_222 OpenJDK 64-Bit Server VM

macgyver16:10:07

still having issues with calva in code hooking up to nREPL

macgyver16:10:15

lein repl works

macgyver16:10:48

almost like the port number is getting piped in correctly or something

macgyver16:10:09

as a recap: - upgraded leiningen to 2.9.1 - completely removed vscode and extensions folder - fresh reinstall of vscode and calva - removed openjdk and installed sdk-man - still getting the same: Jacking in.... Hooking up nREPL sessions....

Dmytro Bunin16:10:04

the connect to repl works?

macgyver16:10:36

No, it doesn't work. That is the problem I am trying to solve.

pez17:10:04

Have you installed a java using sdk-man?

macgyver17:10:10

yes, I have

pez17:10:11

And set it to default.

macgyver17:10:17

how do I set it to default?

pez17:10:45

What does sdk list java say?

pez17:10:30

And what does lein repl give?

macgyver17:10:54

>sdk list java

================================================================================
Available Java Versions
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 AdoptOpenJDK  |     | 13.0.0.j9    | adpt    |            | 13.0.0.j9-adpt      
               |     | 13.0.0.hs    | adpt    |            | 13.0.0.hs-adpt      
               |     | 12.0.2.j9    | adpt    |            | 12.0.2.j9-adpt      
               |     | 12.0.2.hs    | adpt    |            | 12.0.2.hs-adpt      
               |     | 11.0.4.j9    | adpt    |            | 11.0.4.j9-adpt      
               |     | 11.0.4.hs    | adpt    |            | 11.0.4.hs-adpt      
               |     | 8.0.222.j9   | adpt    |            | 8.0.222.j9-adpt     
               |     | 8.0.222.hs   | adpt    |            | 8.0.222.hs-adpt     
 Amazon        |     | 11.0.4       | amzn    |            | 11.0.4-amzn         
               |     | 8.0.222      | amzn    |            | 8.0.222-amzn        
 Azul Zulu     |     | 13.0.0       | zulu    |            | 13.0.0-zulu         
               |     | 12.0.2       | zulu    |            | 12.0.2-zulu         
               |     | 11.0.4       | zulu    |            | 11.0.4-zulu         
               |     | 10.0.2       | zulu    |            | 10.0.2-zulu         
               |     | 9.0.7        | zulu    |            | 9.0.7-zulu          
               |     | 8.0.222      | zulu    |            | 8.0.222-zulu        
               |     | 7.0.232      | zulu    |            | 7.0.232-zulu        
               |     | 6.0.119      | zulu    |            | 6.0.119-zulu        
 Azul ZuluFX   |     | 11.0.2       | zulufx  |            | 11.0.2-zulufx       
               |     | 8.0.202      | zulufx  |            | 8.0.202-zulufx      
 BellSoft      |     | 13.0.0       | librca  |            | 13.0.0-librca       
               |     | 12.0.2       | librca  |            | 12.0.2-librca       
               |     | 11.0.4       | librca  |            | 11.0.4-librca       
               |     | 8.0.222      | librca  |            | 8.0.222-librca      
 GraalVM       |     | 19.2.0       | grl     |            | 19.2.0-grl          
               |     | 19.2.0.1     | grl     |            | 19.2.0.1-grl        
               |     | 19.1.1       | grl     |            | 19.1.1-grl          
               |     | 19.0.2       | grl     |            | 19.0.2-grl          
               |     | 1.0.0        | grl     |            | 1.0.0-rc-16-grl     
       |     | 14.ea.17     | open    |            | 14.ea.17-open       
               |     | 13.0.0       | open    |            | 13.0.0-open         
               |     | 12.0.2       | open    |            | 12.0.2-open         
               |     | 11.0.2       | open    |            | 11.0.2-open         
               |     | 10.0.2       | open    |            | 10.0.2-open         
               |     | 9.0.4        | open    |            | 9.0.4-open          
 SAP           |     | 12.0.2       | sapmchn |            | 12.0.2-sapmchn      
               |     | 11.0.4       | sapmchn |            | 11.0.4-sapmchn      
================================================================================
Use the Identifier for installation:

    $ sdk install java 11.0.3.hs-adpt
================================================================================

pez17:10:00

It doesn't look like you have run sdk install java <some identified>

macgyver17:10:02

ok, and I can run lein repl in the terminal and then Connect to a Runnning REPL in this project and calva does connect

pez17:10:02

It won't actually work very well though. You'll need the dependencies.

macgyver17:10:47

which should I select for <some identified>? I literally don't know which to chose

pez17:10:18

Try with 12.0.2-zulu

pez17:10:50

I use 12.0.2-open currently it seems. 😃

macgyver17:10:19

ok, it is installed, and guess what?! It works!

🎉 4
pez17:10:45

Awesome. I guess something was weird with your java install then.

macgyver17:10:56

so explain what the problem was to me like I am five so I can help someone else out in the future

macgyver17:10:06

cause I had openjdk installed to start out

pez17:10:55

I don't actually know. But it seems something in the installation/configuration caused it to go look for Java's home in the wrong place.

pez17:10:35

So that message that @dmytro.bunin pointed out told us that. Since you couldn't find any java there either. 😃

macgyver17:10:50

for what it's worth, echo $JAVA_HOME is still blank :rolling_on_the_floor_laughing:

macgyver17:10:17

anyways, thanks for the help!

cfehse17:10:20

@adamfranzen @pez I made a small video creating a new lein project on linux and connect using calva. Perhaps we can find out what you are doing differently.

pez17:10:01

Cool video! We will have some good use for that one.

pez17:10:54

Even if @adamfranzen now has it sorted out. It was something weird with the java install, that sdk-man flew in and took care of.

pez17:10:27

Now that you've invested so much time on it, you have to give Clojure a good chance, @adamfranzen 😃 We'll be happy to help with Calva questions here. And if you don't know if it is a Calva or something else question, ask it here anyway.

macgyver17:10:54

@c.fehse that is a cool video, thanks for posting! those were the steps that I was taking, so unfortunately the java install/config was not sorted out and seemed to be causing the issue.

macgyver17:10:36

@pez absolutely, I am excited to learn! I am going through Clojure for the Brave and True

cfehse17:10:48

@adamfranzen Does the lein new <project name> work?

macgyver17:10:58

yes it does

cfehse17:10:20

Okay so there is some sort of java present. But your jack-in process get stuck? (I did not read the complete converstation - sorry)

cfehse17:10:32

The jack-in task shows a commandline similar to the one in the video?

macgyver17:10:48

yes, jack in was getting stuck. I could see that the lein repl server started provided a port number for a split second, then calva would take over to do it's thing, but got stuck at Jacking in.... Hooking up nREPL sessions... and would never find the server

cfehse17:10:00

Can you start a REPL server in the project directory from a terminal with lein repl :headless - and when it is started just terminate it with ctrl-c. After that try to connect with calva again?

macgyver17:10:54

@c.fehse that does work, but again, the original issue that I was having seems to be resolved. I am curious if that would have resolved the original issue

cfehse17:10:59

@adamfranzen I was just asking because a had a similar behavior during my testing - which turned out to be a timing problem in the jack-in process. But don't mind if it is working for you right now it's all good. gg

macgyver17:10:51

yes, thanks for taking a look anyways!

macgyver17:10:26

@pez I really like the logo, both the graphic and the script by the way! Nice work!

pez18:10:20

The timing issue is probably about the filesystem watcher sometimes failing to see the nrepl-port file being created, because for some reason it has been left behind. This used to be a bigger problem before, but I think that sometimes it still happens. Starting the repl and kill it like that is an effective way to delete the port file.

macgyver18:10:21

>deleting the port file this sounds exactly like what was happening!

macgyver18:10:26

I am trying out this comment approach that I have been reading about. I have this comment in my files and it is saved. Now to call this (comment()) and subsequent functions, how do I do that from repl?

(comment
   ;;;; These can be eval'd individually in the editor or in the REPL

  (bar "test")

  (println "hello Clojure")

  (+ 1 2 3))

pez18:10:47

You do it from inside the file. Place the cursor on the line with (bar "test") and run the command Evaluate Top Level Form (defun) (`ctrl+alt+c space`)

pez18:10:27

I recommend to not use the REPL window/prompt much at all.

macgyver19:10:27

☝ exactly what I needed. Thank you

❀ 4