Fork me on GitHub
#beginners
<
2021-02-07
>
theVastSilence02:02:46

@qmstuart alright, i will check it out

theVastSilence02:02:10

@alexmiller what would you recommend besides 4Clojure

borkdude11:02:45

@thevastsilence Also see the gist linked in the topic of this channel: https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f. Oddly enough 4clojure is missing in the original post. /cc @yogthos

phill17:02:52

Trying to set up Leiningen (because deps for Windows is alpha and requires a Dot Net upgrade beyond what came with Windows 10.0.19042). "lein self-install" said it worked. But subsequent "lein" says NullPointerException. This is without any project.clj or profiles. I notice I do not yet have a .m2 directory. There is a stack trace on the NullPointerException, every frame starts with "clojure..." (not Leiningen). HowEver, I can do "java -cp .lein\self-installs\leiningen-2.9.5-standalone.jar clojure.main" and get a REPL prompt wherein "(clojure-version)" says 1.10.1. How could I troubleshoot the Leiningen?

phill18:02:55

lein.bat produces a NullPointerException while executing this line: "java" -client -Dfile.encoding=UTF-8 -Dclojure.compile.path="/target/classes" -Dleiningen.original.pwd="C:\Users\Idiot" -cp "C:\Users\Idiot\.lein\self-installs\leiningen-2.9.5-standalone.jar" clojure.main -m leiningen.core.main

andy.fingerhut18:02:25

You are welcome to copy and paste a full stack trace somewhere, preferably in a Slack discussion thread rather than at the "top level" for such verbose things, or link to one published elsewhere, in case it helps people determine what is going wrong. I do not know off hand of what the problem might be. I did want to note that at least some people use WSL or WSL2 on Windows, to get a more "greased path" for tools that work well on Linux.

phill18:02:26

According to the ("bottom" of the) stack trace, the cause of the NullPointerException from lein.bat is at clojure.main$report_error.invokeStatic(main.clj:601)! So perhaps something went wrong, and Clojure's usual practice of writing an "edn" file also went wrong, and the stack trace reflects only the failed attempt to write the edn?

Alex Miller (Clojure team)19:02:07

I think that’s correct - looks like in pprint’ing the output to the tmp file, an error occurred

phill18:02:11

Exception in thread "main" java.lang.NullPointerException at clojure.core$reduce1.invokeStatic(core.clj:942) at clojure.core$into1.invokeStatic(core.clj:3421) at clojure.core$supers.invokeStatic(core.clj:5559) at clojure.core$isa_QMARK_.invokeStatic(core.clj:5577) at clojure.core$isa_QMARK_.invoke(core.clj:5564) at clojure.lang.Var.invoke(Var.java:393) at clojure.lang.MultiFn.isA(MultiFn.java:123) at clojure.lang.MultiFn.findAndCacheBestMethod(MultiFn.java:173) at clojure.lang.MultiFn.getMethod(MultiFn.java:150) at clojure.lang.MultiFn.getFn(MultiFn.java:154) at clojure.lang.MultiFn.invoke(MultiFn.java:229) at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194) at clojure.pprint$pprint_map$fn__11028$fn__11030.invoke(dispatch.clj:100) at clojure.pprint$pprint_map$fn__11028.invoke(dispatch.clj:100) at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:99) at clojure.pprint$pprint_map.invoke(dispatch.clj:94) at clojure.lang.MultiFn.invoke(MultiFn.java:229) at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194) at clojure.pprint$pprint_map$fn__11028$fn__11030.invoke(dispatch.clj:100) at clojure.pprint$pprint_map$fn__11028.invoke(dispatch.clj:100) at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:99) at clojure.pprint$pprint_map.invoke(dispatch.clj:94) at clojure.lang.MultiFn.invoke(MultiFn.java:229) at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194) at clojure.pprint$pprint$fn__10271.invoke(pprint_base.clj:249) at clojure.pprint$pprint.invokeStatic(pprint_base.clj:248) at clojure.pprint$pprint.invoke(pprint_base.clj:241) at clojure.pprint$pprint.invokeStatic(pprint_base.clj:245) at clojure.pprint$pprint.invoke(pprint_base.clj:241) at clojure.lang.Var.invoke(Var.java:384) at clojure.main$report_error$fn__9160$fn__9161.invoke(main.clj:603) at clojure.main$report_error$fn__9160.invoke(main.clj:602) at clojure.main$report_error.invokeStatic(main.clj:601) at clojure.main$main.invokeStatic(main.clj:666) at clojure.main$main.doInvoke(main.clj:616) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:705) at clojure.main.main(main.java:40)

andy.fingerhut18:02:41

You are trying to run the command lein repl in a directory that contains no project.clj file at all?

andy.fingerhut18:02:27

Does lein version give output, and if so what is that output? (or does it also give errors?)

phill18:02:22

Highly irregular. I repeated the "lein version" and this time I got "Execution error (NullPointerException) at cemerick.pomegranate/loading (pomegranate.clj:1). null. Full report at: ...Local\Temp\clojure-2516445834939944049.edn", and near the top of that file is this: {:via [{:type java.lang.ExceptionInInitializerError, :at [java.lang.J9VMInternals ensureError "J9VMInternals.java" 185]} {:type clojure.lang.Compiler$CompilerException, :message "Syntax error macroexpanding clojure.core/defn- at (cemerick/pomegranate/aether.clj:191:1)."

phill18:02:49

Then I tried "lein version" two more times, and got only the NPE with stack trace of only clojure frames.

phill18:02:21

Maybe there is a race condition in initialization.

caumond18:02:43

You may have some plugins set up somewhere. Are you sure you have clean everything in all possible place . See https://www.github.com/technomancy/leiningen/tree/master/doc%2FPROFILES.md

phill18:02:01

It is a heretofore Java-free Windows 10. Today, I got VS Code and Leiningen and Java. In my .lein directory is nothing but self-installs. Leiningen has not made a .m2 directory yet.

phill18:02:06

I got the Java 11 from http://adoptopenjdk.org . Hoping that doesn't matter because in Windows I despair of achieving a clean uninstall.

andy.fingerhut18:02:29

I doubt that version of Java will cause you any troubles with Clojure.

andy.fingerhut18:02:53

i.e well supported and used by many.

phill18:02:26

Hi Andy! We ran into each other at a Conj. Back in the days of conferences!

andy.fingerhut18:02:54

Cool. Welcome here, and howdy.

phill18:02:55

But I am new to the Windows debacle.

seancorfield18:02:14

Your error message suggests it tried to use the J9 JVM rather than the Adopt OpenJDK 11...

phill18:02:52

Hm! True. But it came from adoptopenjdk.

andy.fingerhut18:02:51

I think Sean is suggesting that you might have multiple JDKs installed on your system, and lein isn't using the AdoptOpenJDK 11 one.

seancorfield18:02:22

As a fellow Windows 10 user, also using VS Code, I would strongly recommend at least considering enabling WSL2 and using that for all your Clojure development. Windows itself is very much a second-class citizen for Clojure work.

seancorfield18:02:19

VS Code makes it seamless because it has a WSL2-Remote extension so you can use VS Code as normal on Windows but have all your Clojure files and REPL etc running on, say, Ubuntu on WSL2.

phill18:02:03

Downloading Adoptopenjdk's "hotspot" variant now...

seancorfield18:02:03

That way you'll be running Linux as far as Clojure is concerned and all the docs/tutorials/books will just work because they're all written for macOS/Linux, not Windows.

phill18:02:02

@seancorfield With the hotspot JVM, lein version says 2.9.5. No drama.

seancorfield18:02:15

Excellent! Progress achieved 🙂

phill18:02:18

How bizarre.

seancorfield18:02:36

I would still recommend looking at WSL2 for doing Clojure dev on Windows 10...

phill19:02:31

Now I am very curious whether Clojure is limited to just Hotspot.

dpsutton19:02:09

You mentioned when invoking Java with lein on the class path worked. It might be worth it to see what lein.bat is doing. It should boil down to a command similar to that. Perhaps you could log some stuff in that if you’re interested

phill19:02:51

Every one of them is Hotspot!

phill19:02:06

Do you remember the history there?

seancorfield19:02:01

I switched from Oracle 8 to Zulu 8 for a while, then Adopt OpenJDK 8, and I've stuck with OpenJDK versions ever since -- I'm using 15 in dev now. I don't think I've tried non-hotspot JVMs.

phill19:02:16

My my, CLJ-2400 was declined because it was J9.

seancorfield19:02:54

"I don't think it's actually specific to J9"

seancorfield19:02:35

It seems it was declined because there's not actually a bug there -- type hinting is needed. Unless I'm misreading Alex's comment.

phill19:02:19

Oh good. I missed the "don't"

Alex Miller (Clojure team)19:02:30

I have tested with J9 in the past and did have some unusual test failures in the Clojure test suite

Alex Miller (Clojure team)19:02:17

I can’t remember if they were unusual because tests highlighted jvm differences (like hash ordering/reflector ordering kinds of things) or if it was something deeper

phill19:02:41

I remember a difference in stack frames.

Alex Miller (Clojure team)19:02:54

It would not surprise me at all if things like the locking verifier issue fixed in 1.10.2 would have shown up in J9

Alex Miller (Clojure team)19:02:46

I don’t recall anything with stack map frames. Not saying you’re wrong, just don’t remember that.

hiredman19:02:22

The error mentions pomegranate, so the error is likely coming from the lein jvm, not the project jvm, so it will be using whatever (older) version of clojure is bundled with that version of lein

hiredman19:02:32

(but 2.9.5 looks like it bundles 1.10.x anyway

phill20:02:21

My my! Same thing happens in Linux. There is a hex on Leiningen & J9 version 11.

phill20:02:26

I feel like making an issue out recording this. In the name of Science purely. I think I will put the issue on the Leiningen project since that's the reproducible story I know.

hiredman20:02:47

If you want a more minimal test case you should see if it happens using clj (and deps.edn) loading the pomegranate library. You will be able to eliminate the two jvm thing in lein, and try it against different clojure versions (tricky to do in the lein jvm because lein bundles clojure)

ej22:02:42

Hello. I am following the book Web development with Clojure (3rd edition), and I have got stuck. The book showed me some database tests, but after typing them in I am getting an error trying to run them.

ej22:02:49

"Could not locate guestbook/test/db/core__init.class, guestbook/test/db/core.clj or guestbook/test/db/core.cljc on classpath."

seancorfield22:02:05

@endrejoh that means it is looking for a namespace guestbook.test.db.core which it would expect to find in guestbook/test/db/core.clj under either your src or test folder.

seancorfield22:02:53

Kind of unusual to have .test. in the middle of a namespace though. Whereabouts are you in the book? I think I have a copy and can look at the examples...

seancorfield22:02:07

Looks like it is referring to this file: http://media.pragprog.com/titles/dswdcloj3/code/guestbook/test/clj/guestbook/test/db/core.clj -- so it is expecting a file under your test/clj folder, with a path guestbook/test/db/core.clj

seancorfield22:02:44

According to the book, "The project already comes with some default test operations defined. These are found in the test folder of the application. The database tests are in the test/clj/guestbook/test/db/core.clj file."

ej23:02:15

I'm wondering if I'm using a newer version of the luminus template, so that the folder structure is a little bit different. The file with tests that came with my project was called core_test.clj, and it was inside this folder:

ej23:02:53

It looks like it is lacking one of the /test/ folders. I think the safe bet is to just create the project from scratch, and make sure I use the same version of the template as the book 🙂

ej23:02:12

Thank you for the help, @seancorfield!

seancorfield23:02:38

Having test files ending in _test.clj (and their namespaces ending in -test) is a lot more common. I'm a bit surprised at what's in the book (mine is 3rd Ed, Beta 16 -- not sure what Ed you're reading?).

seancorfield23:02:45

@yogthos Are we reading that section on tests correctly in your book?

seancorfield23:02:23

(it's not day time for him but he should see that tomorrow and respond)

yogthos23:02:10

I might've missed it when updating the part on tests though

seancorfield23:02:22

Yeah, that PR makes sense -- adding _test to filenames (`-test` to namespaces). So it looks like that section of the book just hasn't caught up and the source code on http://media.pragprog.com still follows the old Luminus convention. Do you want me to go log that somewhere @yogthos? There's a forum for the beta book isn't there?

yogthos23:02:29

oh yeah that would be great, let me find the url for the forum

seancorfield23:02:39

(In VS Code/Clover, I have a hot key bound to code that runs "associated tests" so when I'm in, say, guestbook.db.core it would look for guestbook.db.core-test --- note: no .test. in the middle!)