Fork me on GitHub
#cursive
<
2021-12-04
>
p-himik09:12:07

A bit confused as to what's happening. I'm using an older version of Cursive, 1.10.2-2020.2, and I have the "Clojure Deps" settings section using the CLI tools, version 1.10.3.967. I just added this alias to my deps.edn:

:test       {:extra-paths ["test"]
                        :extra-deps  {io.github.cognitect-labs/test-runner
                                      {:git/tag "v0.5.0" :git/sha "48c3c67"}}
                        :main-opts   ["-m" "cognitect.test-runner"]
                        :exec-fn     cognitect.test-runner.api/test}
When I run clj -X:test, it works just fine. clj -A:test -Spath works just fine as well and has the correct dependency on the classpath. However, when I mark the :test alias in the "Clojure Deps" panel in IDEA, I get:
12:12	Errors during project resolution
			The following errors were found during project resolve:
			/home/p-himik/.../deps.edn:
			Library io.github.cognitect-labs/test-runner has missing :sha in coordinate.
If Cursive is using clj CLI tool, how can the above error be explained? How can I fix it?

cfleming08:12:14

@U2FRKM4TW I think you might be being hit by https://github.com/cursive-ide/cursive/issues/2105, which is fixed in 1.10.3. Could you check /usr/local/lib/clojure/libexec and see if you have multiple versions there? If so, please delete all but the one you want and try again.

p-himik08:12:37

Seems like it's something else. The symptoms are different, and even after removing everything but clojure-tools-1.10.3.967.jar and exec.jar and restarting IDEA, the behavior is still the same.

cfleming08:12:34

Ok, I’ll see if I can reproduce that tomorrow.

p-himik08:12:24

Trying to poke around with strace right now.

p-himik09:12:53

Love me some bizarre behavior. After attaching strace, Cursive started erroring out with Could not create shim: Could not create shim. The stacktrace in the logs:

2021-12-05 11:59:35,974 [ 361182]  ERROR - #cursive.build.BuildSystemUtil - Could not create shim 
java.lang.RuntimeException: Could not create shim
	at cursive.shim.ShimProvider.getShim(Shim.kt:141)
	at cursive.shim.ShimProvider.withShim(Shim.kt:108)
	at cursive.deps.DepsProjectDetails.doGetDetails(Project.kt:167)
	at cursive.deps.DepsProjectDetails.doGetDetails(Project.kt:85)
	at cursive.build.BuildSystemProjectDetails.getProjectDetails(BuildSystem.kt:42)
	at cursive.build.BuildSystemProjectsManager$reimportAllProjects$$inlined$synchronized$lambda$1.run(BuildSystemManager.kt:150)
	at cursive.build.BuildSystemUtil$runTask$1$1.run(BuildSystemUtil.kt:93)
	at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:935)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:442)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:235)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:170)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:629)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:581)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:157)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:235)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NullPointerException
	at org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.postInvoke(ClojureRuntimeShimImpl.java:49)
	at org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.init(ClojureRuntimeShimImpl.java:31)
	at org.projectodd.shimdandy.ClojureRuntimeShim.newRuntime(ClojureRuntimeShim.java:26)
	at cursive.shim.ShimBootstrap.apply(ShimBootstrap.java:26)
	at cursive.shim.Shim$createShimProvider$1.apply(Shim.kt:73)
	at cursive.shim.ShimProvider$createShim$1.invoke(Shim.kt:148)
	at cursive.shim.ShimProvider$createShim$1.invoke(Shim.kt:90)
	at cursive.application.ApplicationKt$sam$java_lang_Runnable$0.run(Application.kt)
	at com.intellij.util.RunnableCallable.call(RunnableCallable.java:20)
	at com.intellij.util.RunnableCallable.call(RunnableCallable.java:11)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.call(ApplicationImpl.java:268)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	... 7 more
At the same time, strace shows that one of the IDEA's processes is trying to find libjawt.so but in wrong places for some reason, and fails with SIGSEGV. Funny thing is, now dependency resolution doesn't work at all - in other projects, after killing strace and restarting IDEA along with purging all indexes. I have no clue how attaching strace could've seemingly prevented IDEA from looking for libjawt.so at the right place.

p-himik09:12:39

Ah, I think I know what's going on. libjawt.so was just a random coincidence. I see this line in the strace output: stat("/usr/local/lib/clojure/libexec/clojure-tools-1.10.2.796.jar", 0x7f133adf3f40) = -1 ENOENT (No such file or directory) So for some reason, Cursive is still trying to access an older version of the jar, one that I removed.

p-himik14:12:08

@U0567Q30W Just FYI, got it fixed by removing ~/.clojure/.cpcache.

cfleming19:12:19

That is super weird. I’m pretty sure that removing .cpcache wouldn’t be the thing that fixed it, since Cursive only calls the CLI script for -Sdescribe, which I don’t think uses it. I’m honestly not sure what might have actually fixed it though. I’m pretty sure that that bug is the underlying cause.

p-himik20:12:39

Well, FWIW that's the only thing I did after which the behavior actually changed - tried multiple IDEA restarts with cache clearing (while using strace at different stages), and all the time strace was showing the old clojure-tools jar being used. Didn't do any other changes myself apart from removing the old jars in the first place.

p-himik20:12:17

And BTW if you run clojure -Sdescribe within ~/home/.clojure, that .cpcache directory is definitely used. But only for the stat syscall, so maybe that's not important.

cfleming20:12:05

Ohh… actually, I think what you probably had to do was go to the Deps settings, change something, hit apply and then change it back and hit apply again. The path to the jar file that actually gets used is updated during that process.

cfleming20:12:38

(or some similar combination which would provoke IntelliJ to update that value in the Settings dialog).

p-himik20:12:25

Oh, you're absolutely right! Not sure how it flew out of my head, sorry for the confusion.

cfleming20:12:56

No worries, it’s confusing that the process of configuring deps can later provoke this sort of error, for sure…

p-himik20:12:07

For the sake of my own education - where is this setting stored? I didn't find the old version with grep so I must've missed some place.

cfleming21:12:29

So in IntelliJ there are project-specific settings and global app-wide ones. This is app-wide, so it’s not stored in the project itself. You can find those directories here: https://www.jetbrains.com/help/idea/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-directory. On my Mac, the relevant file is at: /Users/colin/Library/Application Support/JetBrains/IntelliJIdea2021.3/settingsRepository/repository/clojure-deps.settings.xml

p-himik21:12:27

Oh, I see it now, thanks!