cursive icon indicating copy to clipboard operation
cursive copied to clipboard

Checkouts missing from classpath on Windows since 1.10.2

Open daviesian opened this issue 3 years ago • 3 comments

I have an IntelliJ project with two modules, both leiningen projects, one called main and one called lib. The main/checkouts directory has a symlink to lib (and lib has been lein installed), so the source directories from lib are on the classpath when running lein repl or lein run manually. So far so good.

However, when running the main module using Cursive 1.10.2 on Windows 10 (in several versions of IntelliJ), the checkouts are missing from the classpath. This is true when running as a Local REPL configuration, or as a Clojure Application set to Run -main from Clojure namespace. However, all the checkouts do appear on the classpath when running as a Clojure Application set to Run Clojure Script.

Manually downgrading Cursive to 1.10.1 fixes the problem. Right now this means I can't upgrade Cursive any further, and at some point presumably this will stop me upgrading IntelliJ as support for older versions is dropped.

I would be happy to provide any further information required to help get to the bottom of this, just let me know. Thanks!

daviesian avatar May 18 '21 13:05 daviesian

The same is happening to me on MacOS, Cursive 1.12.4-2022.1

antonmos avatar Jul 06 '22 22:07 antonmos

There is a number of other issues open about problems with cursive+lein checkouts. Can the maintainers please take a look? lein checkouts is unsuable at the momemt.

antonmos avatar Jul 06 '22 22:07 antonmos

This has continued to drive us mad for more than 2 years, so today I snapped and went digging for a workaround. It seems that the problem is with the :checkout-deps-shares project setting. In particular, my hypothesis is that Cursive causes the :source-paths (etc) to be relative to the project root, whereas leiningen on the command line returns them as fully-qualified absolute paths. This means that when running under Cursive, the checkouts directories are calculated incorrectly and are therefore omitted from the classpath.

Anyway, whether or not this hypothesis is correct, the workaround is to manually reassemble a working value for :checkout-deps-shares, which I do with the following profile in ~/.lein/profiles.clj:

{:cursive-fix {:checkout-deps-shares ^:replace [#=(eval (fn [p] (map #(str (:root p) "/" %) (:source-paths p))))
                                                #=(eval (fn [p] (str (:root p) "/" (:compile-path p))))
                                                #=(eval (fn [p] (map #(str (:root p) "/" %) (:resource-paths p))))
                                                #=(eval leiningen.core.classpath/checkout-deps-paths)]}}

Then, when creating an IntelliJ run configuration, I tell Cursive to activate this profile:

image

That causes the correct checkouts directories to be added to the classpath, and then everything works again. Particular thanks to @jakemcc for his excellent blog post that helped point me in the right direction.

I hope this helps others with the same problem! Of course, you may need to tweak the profile (or add it to project.clj directly) if you have customised :checkout-deps-shares in any of your library projects.

daviesian avatar Nov 11 '23 12:11 daviesian