Skip to content

Instantly share code, notes, and snippets.

@mfikes
Last active October 31, 2020 12:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mfikes/f803fef3013927c376063a3d72b69d60 to your computer and use it in GitHub Desktop.
Save mfikes/f803fef3013927c376063a3d72b69d60 to your computer and use it in GitHub Desktop.
Using `lein-tools-deps` from Cursive (on macOS)

Note: These workarounds covered issues in lein-tools-deps 0.3.0-SNAPSHOT. If using 0.4.1 or later, you should not encounter the issues below.

The following provides some workarounds for some issues when using lein-tools-deps from Cursive on macOS.

Path to clojure

By default, the lein-tools-deps plugin won't see /usr/local/bin/clojure when Cursive processes project.clj, as it evidently has a degenerate path.

You will see an error like the following in the IntelliJ Event Log when it tries to process your project.clj file:

8:44 PM	Error reading /Users/mfikes/Projects/foo/project.clj
	Cannot run program "clojure": error=2, No such file or directory
	error=2, No such file or directory

A workaround is to instead launch IntelliJ from a terminal (which has /usr/local/bin in its PATH), and it will inherit the terminal's path:

open -a "IntelliJ IDEA"

A potential fix for this is in the works.

Path to deps.edn

When processing project.clj, Cursive will be running with a working directory such as /Applications/IntelliJ IDEA.app/Contents/bin (i.e. not your project directory). This will cause lein-tools-deps to fail to find project-level deps.edn file, presuming you have

  :tools/deps [:system :home :project]

in your project.clj. The workaround for this is to remove :project from this vector, ensure you are specifying

   [lein-tools-deps "0.3.0-SNAPSHOT"]

or later in your :plugins vector so that you have #15, and then specify the fully-qualified path to your deps.edn file:

  :tools/deps [:system :home "/Users/myhome/my-project/deps.edn"]

A potential fix for this is in the works.

Can't start Cursive REPL

If you try to start a REPL in Cursive, you may see:

Error loading clojure.tools.nrepl.server: Could not locate clojure/tools/nrepl/server__init.class or clojure/tools/nrepl/server.clj on classpath.

You can explicitly add this dep to your deps.edn

org.clojure/tools.nrepl {:mvn/version "0.2.12"}

See #27

Additional "Extra-Project" Source Paths

If you have :paths in your deps.edn, or Git Deps, or a :local/root dep, you will end up seeing paths to items outside of your project in listed at the top of the Project navigator in the upper left. You may even be asked to submit an automated error report for Cursive if it sees these:

The file 'src' is not under content entry root '/Applications/IntelliJ IDEA.app/Contents/bin/src'
java.lang.Throwable: The file 'src' is not under content entry root '/Applications/IntelliJ IDEA.app/Contents/bin/src'

For :paths, you will see that each entry will be reflected in a path under /Applications/IntelliJ IDEA.app/Conents/bin/. This particular aspect is fixed with this PR.

As far as I can tell, these are annoying but harmless.

Error Regarding complete.core

If launching a REPL in Cursive you may see this.

Error loading complete.core: Could not locate complete/core__init.class or complete/core.clj on classpath.

AFAICT this is benign.

See #27

Odd Zip Errors

If you are tring to get thing runnning and encounter an error in the Event log with a message like

  • invalid distance too far back
  • invalid block type
  • invalid code lengths set
  • invalid stored block lengths

or anything that looks like a low-level zip issue, do a File > Invalidate Caches / Restart ... to clear up the issue.

(My guess is that this may reflect partial JAR or ZIP files being placed in an IntelliJ cache without proper cleanup if anything goes wrong. It also might be associated with updating the -SNAPSHOT version of the plugin, in which case it won't affect bona fide releases.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment