beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
theVastSilence 2021-02-07T02:37:46.144400Z

@qmstuart alright, i will check it out

theVastSilence 2021-02-07T02:38:10.144900Z

@alexmiller what would you recommend besides 4Clojure

borkdude 2021-02-07T11:02:45.145200Z

@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

theVastSilence 2021-02-07T13:58:00.145500Z

Thanks @borkdude

2021-02-07T17:29:52.150400Z

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?

2021-02-07T18:18:55.151400Z

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

2021-02-07T18:23:25.155600Z

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.

2021-02-07T18:24:26.156500Z

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?

2021-02-07T18:25:11.156800Z

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)

2021-02-07T18:29:41.157400Z

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

2021-02-07T18:30:27.158Z

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

2021-02-07T18:42:22.159Z

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)."

2021-02-07T18:43:49.160700Z

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

2021-02-07T18:44:21.161Z

Maybe there is a race condition in initialization.

caumond 2021-02-07T18:46:43.161800Z

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

2021-02-07T18:50:01.163500Z

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.

2021-02-07T18:51:06.164400Z

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

2021-02-07T18:51:29.164500Z

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

2021-02-07T18:51:53.164700Z

i.e well supported and used by many.

2021-02-07T18:52:26.164900Z

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

2021-02-07T18:52:54.165100Z

Cool. Welcome here, and howdy.

2021-02-07T18:52:55.165300Z

But I am new to the Windows debacle.

seancorfield 2021-02-07T18:53:14.165500Z

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

2021-02-07T18:53:52.165700Z

Hm! True. But it came from adoptopenjdk.

2021-02-07T18:54:51.165900Z

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

seancorfield 2021-02-07T18:55:22.166100Z

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.

seancorfield 2021-02-07T18:56:19.166300Z

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.

2021-02-07T18:57:03.166500Z

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

seancorfield 2021-02-07T18:57:03.166700Z

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.

2021-02-07T18:59:02.166900Z

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

seancorfield 2021-02-07T18:59:15.167100Z

Excellent! Progress achieved 🙂

2021-02-07T18:59:18.167300Z

How bizarre.

seancorfield 2021-02-07T18:59:36.167500Z

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

2021-02-07T19:00:31.168200Z

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

dpsutton 2021-02-07T19:01:09.169600Z

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

seancorfield 2021-02-07T19:01:16.169800Z

These are the JVMs that Clojure is tested on https://build.clojure.org/job/clojure-test-matrix/

2021-02-07T19:01:51.170Z

Every one of them is Hotspot!

2021-02-07T19:02:06.170200Z

Do you remember the history there?

seancorfield 2021-02-07T19:03:01.170400Z

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.

2021-02-07T19:04:16.170600Z

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

seancorfield 2021-02-07T19:05:54.170800Z

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

seancorfield 2021-02-07T19:06:35.171Z

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

2021-02-07T19:07:19.171200Z

Oh good. I missed the "don't"

alexmiller 2021-02-07T19:10:07.172600Z

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

alexmiller 2021-02-07T19:12:30.173600Z

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

alexmiller 2021-02-07T19:14:17.175700Z

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

2021-02-07T19:14:41.176600Z

I remember a difference in stack frames.

alexmiller 2021-02-07T19:15:54.177500Z

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

alexmiller 2021-02-07T19:16:46.178500Z

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

2021-02-07T19:30:22.179500Z

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

2021-02-07T19:32:32.179700Z

(but 2.9.5 looks like it bundles 1.10.x anyway

2021-02-07T19:32:35.179900Z

)

2021-02-07T20:03:21.180100Z

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

2021-02-07T20:04:26.180300Z

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.

2021-02-07T20:47:47.180500Z

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)

ej 2021-02-07T22:19:42.182600Z

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.

ej 2021-02-07T22:19:49.182800Z

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

seancorfield 2021-02-07T22:49:05.185400Z

@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.

seancorfield 2021-02-07T22:49:53.186300Z

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...

seancorfield 2021-02-07T22:52:07.187Z

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

seancorfield 2021-02-07T22:53:44.187400Z

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."

ej 2021-02-07T23:16:15.189500Z

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:

ej 2021-02-07T23:16:53.190300Z

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 🙂

ej 2021-02-07T23:17:12.190700Z

Thank you for the help, @seancorfield!

seancorfield 2021-02-07T23:45:38.191900Z

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?).

seancorfield 2021-02-07T23:46:45.192100Z

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

seancorfield 2021-02-07T23:47:23.192600Z

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

yogthos 2021-02-07T23:52:31.193Z

the book intends to follow this change in Luminus https://github.com/luminus-framework/luminus-template/pull/508

yogthos 2021-02-07T23:53:10.193600Z

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

seancorfield 2021-02-07T23:58:22.195400Z

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?

yogthos 2021-02-07T23:59:29.196700Z

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

seancorfield 2021-02-07T23:59:39.196900Z

(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!)