Fork me on GitHub
#clj-on-windows
<
2023-03-23
>
jjttjj19:03:44

I installed the latest clojure-msi version (1252) and now am getting this error (🧵). Does this look familiar to anyone?

✅ 2
jjttjj19:03:56

$ clj -Sverbose -Srepro
deps.clj version = 1.11.1.1252
version          = 1.11.1.1224
install_dir      = C:\Users\justin\AppData\Local\Apps\clojure\
config_dir       = C:\Users\justin\.config\clojure
config_paths     = C:\Users\justin\AppData\Local\Apps\clojure\deps.edn C:\Users\justin\.config\clojure\deps.edn deps.edn
cache_dir        = .cpcache
cp_file          = .cpcache\795F3581F76A585DE3044ED0B7DE8FED.cp

Refreshing classpath
Error building classpath. Cannot invoke "java.io.File.getParentFile()" because "the_file" is null
java.lang.NullPointerException: Cannot invoke "java.io.File.getParentFile()" because "the_file" is null
	at $write_file.invokeStatic(io.clj:52)
	at clojure.tools.deps.script.make_classpath2$run.invokeStatic(make_classpath2.clj:188)
	at clojure.tools.deps.script.make_classpath2$_main.invokeStatic(make_classpath2.clj:228)
	at clojure.tools.deps.script.make_classpath2$_main.doInvoke(make_classpath2.clj:195)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:705)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.main$main_opt.invokeStatic(main.clj:514)
	at clojure.main$main_opt.invoke(main.clj:510)
	at clojure.main$main.invokeStatic(main.clj:664)
	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)

borkdude19:03:23

Are you running this in or outside a project? (Not that it should matter, both should work)

jjttjj19:03:27

it was the same on both... wait this is only happening in the emacs shells, seems to work in powershell

jjttjj19:03:12

Going to try the old "restart everything trick", it might be that

borkdude19:03:19

and in cmd.exe?

jjttjj19:03:13

yup works there too. I think it has to do with emacs seeing the wrong environment variables (despite restarting it)

jjttjj19:03:11

Ah yeah, that was it. I had another instance of emacs open that was causing it to not refresh the env. working now. Thanks for looking

borkdude19:03:30

so with which env var not set did you get the error?

borkdude19:03:48

XDG_CACHE or so?

jjttjj19:03:42

I think it might have been JAVA_HOME? as that was giving me another issue that seemed related, but haven't verified that that's used in tools.deps

borkdude19:03:16

I don't see how JAVA_HOME would cause the above error, it seems tools deps was writing to a directory that didn't exist or so

jjttjj19:03:49

hmm I do use the XDG_CONFIG_HOME for clojure but I don't think that would have been unset. So now I'm not so sure it was that. Going to see if I can reproduce it

borkdude19:03:55

maybe if you set XDG_CONFIG_HOME or CACHE_HOME to a non-existing directory or empty string, the error could happen?

borkdude19:03:07

I can trigger a warning with that, but different:

$ XDG_CACHE_HOME="" bb clojure
Error building classpath. Can't create directory: /clojure
Exception in thread "main" java.io.FileNotFoundException: /clojure/940AA8FA0E8C78469532CDFC872761FE.cp (No such file or directory)

jjttjj19:03:40

Yup that seems to be it for me:

> $env:XDG_CACHE_HOME = ''; clj
Error building classpath. Cannot invoke "java.io.File.getParentFile()" because "the_file" is null
java.lang.NullPointerException: Cannot invoke "java.io.File.getParentFile()" because "the_file" is null
        at $write_file.invokeStatic(io.clj:52)
        at clojure.tools.deps.script.make_classpath2$run.invokeStatic(make_classpath2.clj:188)
        at clojure.tools.deps.script.make_classpath2$_main.invokeStatic(make_classpath2.clj:228)
        at clojure.tools.deps.script.make_classpath2$_main.doInvoke(make_classpath2.clj:195)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.main$main_opt.invokeStatic(main.clj:514)
        at clojure.main$main_opt.invoke(main.clj:510)
        at clojure.main$main.invokeStatic(main.clj:664)
        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)

jjttjj19:03:58

arg wait no sorry that was in an old shell with the bad env at least I have that to look at now one sec

jjttjj20:03:26

Not sure if this is the cause but it seems related: DEPS_CLJ_TOOLS_VERSION was pointing to the old version that was no longer installed in the stale env. And which doesn't exist as a directory in ~/.deps.clj/ I can't immediately see how that leads to the exact error. On a quick glance it seems like it could cause issues in deps.clj, such as here: https://github.com/borkdude/deps.clj/blob/b2356ff4b28e3b115479d2d3d6e4135bf20f9150/deps.clj#L614-L618

borkdude20:03:45

ah yes, that can surely mess things up

borkdude20:03:14

since the older or newer tools version will or won't pass certain things like jvm-file, basis-file, etc

borkdude20:03:30

there lately have been some changes there