clj-on-windows

2023-03-23T19:08:44.594769Z

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

✅ 1
2023-03-23T19:08:56.226659Z

$ 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)

borkdude 2023-03-23T19:10:23.251879Z

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

2023-03-23T19:11:27.785399Z

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

2023-03-23T19:12:12.497569Z

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

borkdude 2023-03-23T19:12:19.382109Z

and in cmd.exe?

2023-03-23T19:13:13.308179Z

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

borkdude 2023-03-23T19:14:41.189599Z

ok

2023-03-23T19:16:11.864459Z

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

borkdude 2023-03-23T19:16:30.825469Z

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

borkdude 2023-03-23T19:16:48.582159Z

XDG_CACHE or so?

2023-03-23T19:17:42.668099Z

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

borkdude 2023-03-23T19:18:16.638839Z

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

2023-03-23T19:32:49.132949Z

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

borkdude 2023-03-23T19:34:55.446269Z

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

borkdude 2023-03-23T19:36:07.727229Z

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)

2023-03-23T19:39:40.166699Z

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)

2023-03-23T19:41:58.802799Z

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

2023-03-23T20:10:26.490919Z

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

borkdude 2023-03-23T20:10:45.320969Z

ah yes, that can surely mess things up

borkdude 2023-03-23T20:11:14.604379Z

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

borkdude 2023-03-23T20:11:30.826709Z

there lately have been some changes there