Skip to content

Remove enrich-classpath support from cider-jack-in #3816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ jobs:
# problem by rerunning the tests more than once.
eldev -p -dtTC test --test-type integration || eldev -p -dtTC test --test-type integration

- name: Run tests that need enrich-classpath
if: "!startsWith(matrix.os, 'windows')"
run: |
cd dev; ../clojure.sh clojure -M:gen; cd -
wc -l test/File.edn
eldev -p -dtTC test --test-type enrich || eldev -p -dtTC test --test-type enrich

- name: Test clojure-ts-mode
if: startsWith (matrix.emacs_version, '30')
run: |
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## master (unreleased)

### New features

### Changes

- [#3816](https://github.com/clojure-emacs/cider/issues/3816): **(Breaking)** Remove enrich-classpath support from cider-jack-in.

### Bugs fixed

## 1.18.0 (2025-04-30)

### New features
Expand Down
5 changes: 2 additions & 3 deletions Eldev
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
(eldev-pcase-exhaustive cider-test-type
(`main "./test/*/")
(`integration '("./test/" "!./test/integration"))
(`enrich '("./test/" "!./test/enrich"))
(`clojure-ts-mode '("./test/*/" "!./test/clojure-ts-mode"))
(`all '("./test/*/" "!./test/integration")))
"test/integration/projects"
Expand All @@ -34,12 +33,12 @@
"test/cider-tests--no-auto.el"))

(eldev-defoption cider-test-selection (type)
"Select tests to run; type can be `main', `integration', `enrich', `clojure-ts-mode' or `all'"
"Select tests to run; type can be `main', `integration', `clojure-ts-mode' or `all'"
:options (-T --test-type)
:for-command test
:value TYPE
:default-value cider-test-type
(unless (memq (intern type) '(main integration enrich clojure-ts-mode all))
(unless (memq (intern type) '(main integration clojure-ts-mode all))
(signal 'eldev-wrong-option-usage `("unknown test type `%s'" ,type)))
(setf cider-test-type (intern type)))

Expand Down
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@ lint: clean
compile: clean
eldev -dtT compile --warnings-as-errors

test/File.edn:
cd dev; ../clojure.sh clojure -M:gen

test-all: clean test/File.edn
test-all: clean
eldev -dtT -p test --test-type all

test-enrich: clean test/File.edn
eldev -dtT -p test --test-type enrich

test-integration: clean
eldev -dtT -p test --test-type integration

Expand Down
2 changes: 1 addition & 1 deletion cider-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ The default value in nREPL is 1024."
:group 'cider
:package-version '(cider . "0.25.0"))

(defcustom cider-download-java-sources nil
(defcustom cider-download-java-sources t
"Whether to automatically download source artifacts for 3rd-party Java classes.

When enabled, CIDER will attempt to download source JARs from Maven for
Expand Down
77 changes: 9 additions & 68 deletions cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ By default we favor the project-specific shadow-cljs over the system-wide."
(make-obsolete-variable 'cider-gradle-global-options 'cider-gradle-parameters "1.8.0")
(make-obsolete-variable 'cider-babashka-global-options 'cider-babashka-parameters "1.8.0")
(make-obsolete-variable 'cider-nbb-global-options 'cider-nbb-parameters "1.8.0")
(make-obsolete-variable 'cider-enrich-classpath nil "1.19.0")

(defcustom cider-jack-in-default
(if (executable-find "clojure") 'clojure-cli 'lein)
Expand Down Expand Up @@ -453,49 +454,16 @@ The plist supports the following keys
(_ (user-error "Unsupported project type `%S'" project-type))))

(defcustom cider-enrich-classpath nil
"If t, use enrich-classpath for adding sources/javadocs to the classpath.

enrich-classpath is a Clojure CLI shim, and Leiningen plugin.

This classpath expansion is done in a clean manner,
without interfering with classloaders."
"Removed."
:type 'boolean
:package-version '(cider . "1.2.0")
:safe #'booleanp)

(defun cider--get-enrich-classpath-lein-script ()
"Returns the location of enrich-classpath's lein.sh wrapper script."
(when-let ((cider-location (locate-library "cider.el" t)))
(concat (file-name-directory cider-location)
"lein.sh")))

(defun cider--get-enrich-classpath-clojure-cli-script ()
"Returns the location of enrich-classpath's clojure.sh wrapper script."
(when-let ((cider-location (locate-library "cider.el" t)))
(concat (file-name-directory cider-location)
"clojure.sh")))

(defun cider-jack-in-resolve-command (project-type)
"Determine the resolved file path to `cider-jack-in-command'.
Throws an error if PROJECT-TYPE is unknown."
(pcase project-type
('lein (let ((r (cider--resolve-command cider-lein-command)))
(if (and cider-enrich-classpath
(not (eq system-type 'windows-nt))
(executable-find (cider--get-enrich-classpath-lein-script)))
(concat "bash " ;; don't assume lein.sh is executable - MELPA might change that
(cider--get-enrich-classpath-lein-script)
" "
r)
r)))
('clojure-cli (if (and cider-enrich-classpath
(not (eq system-type 'windows-nt))
(executable-find (cider--get-enrich-classpath-clojure-cli-script)))
(concat "bash " ;; don't assume clojure.sh is executable - MELPA might change that
(cider--get-enrich-classpath-clojure-cli-script)
" "
(cider--resolve-command cider-clojure-cli-command))
(cider--resolve-command cider-clojure-cli-command)))
('lein (cider--resolve-command cider-lein-command))
('clojure-cli (cider--resolve-command cider-clojure-cli-command))
('babashka (cider--resolve-command cider-babashka-command))
;; here we have to account for the possibility that the command is either
;; "npx shadow-cljs" or just "shadow-cljs"
Expand Down Expand Up @@ -649,12 +617,8 @@ Added to `cider-jack-in-lein-plugins' (which see) when doing
"Return a normalized list of Leiningen plugins to be injected.
See `cider-jack-in-lein-plugins' for the format, except that the list
returned by this function does not include keyword arguments."
(let ((plugins (if cider-enrich-classpath
(append cider-jack-in-lein-plugins
`(("cider/cider-nrepl" ,cider-injected-middleware-version)
("mx.cider/lein-enrich-classpath" "1.19.3")))
(append cider-jack-in-lein-plugins
`(("cider/cider-nrepl" ,cider-injected-middleware-version))))))
(let ((plugins (append cider-jack-in-lein-plugins
`(("cider/cider-nrepl" ,cider-injected-middleware-version)))))
(thread-last plugins
(seq-filter
(lambda (spec)
Expand Down Expand Up @@ -765,18 +729,6 @@ of EXCLUSIONS can be provided as well. The returned
string is quoted for passing as argument to an inferior shell."
(shell-quote-argument (format "[%s %S%s]" (car list) (cadr list) (cider--lein-artifact-exclusions exclusions))))

(defun cider--extract-lein-profiles (lein-params)
"Extracts a list of ('with-profile ...' and a repl command from LEIN-PARAMS).

If no `with-profile' call was found,
returns an empty string as the first member."
(or (when-let* ((pattern "\\(with-profiles?\\s-+\\S-+\\)")
(match-start (string-match pattern lein-params))
(match-end (match-end 0)))
(list (concat (substring lein-params match-start match-end) " ")
(string-trim (substring lein-params match-end))))
(list "" lein-params)))

(defun cider-lein-jack-in-dependencies (global-opts params dependencies dependencies-exclusions lein-plugins &optional lein-middlewares)
"Create lein jack-in dependencies.
Does so by concatenating GLOBAL-OPTS, DEPENDENCIES, with DEPENDENCIES-EXCLUSIONS
Expand All @@ -802,16 +754,7 @@ removed, LEIN-PLUGINS, LEIN-MIDDLEWARES and finally PARAMS."
`(,(concat "update-in :jvm-opts conj '\"-Djdk.attach.allowAttachSelf\"'"))))
" -- ")
" -- "
(if (not cider-enrich-classpath)
params
;; enrich-classpath must be applied after the `with-profile` call, if present,
;; so that it can also process the classpath that is typically expanded by the presence of a set of profiles:
(let* ((profiles-and-repl-call (cider--extract-lein-profiles params))
(profiles (car profiles-and-repl-call))
(repl-call (nth 1 profiles-and-repl-call)))
(concat profiles
"update-in :middleware conj cider.enrich-classpath.plugin-v2/middleware -- "
repl-call)))))
params))

(defun cider--dedupe-deps (deps)
"Removes the duplicates in DEPS."
Expand Down Expand Up @@ -1404,8 +1347,7 @@ With the prefix argument,
allow editing of the jack in command; with a double prefix prompt for all
these parameters."
(interactive "P")
(let ((cider-enrich-classpath nil) ;; ensure it's disabled for cljs projects, for now
(cider-jack-in-dependencies (append cider-jack-in-dependencies cider-jack-in-cljs-dependencies))
(let ((cider-jack-in-dependencies (append cider-jack-in-dependencies cider-jack-in-cljs-dependencies))
(cider-jack-in-lein-plugins (append cider-jack-in-lein-plugins cider-jack-in-cljs-lein-plugins))
(cider-jack-in-nrepl-middlewares (append cider-jack-in-nrepl-middlewares cider-jack-in-cljs-nrepl-middlewares))
(orig-buffer (current-buffer)))
Expand Down Expand Up @@ -1433,8 +1375,7 @@ with a double prefix prompt for all these parameters.
When SOFT-CLJS-START is non-nil, start cljs REPL
only when the ClojureScript dependencies are met."
(interactive "P")
(let ((cider-enrich-classpath nil) ;; ensure it's disabled for cljs projects, for now
(cider-jack-in-dependencies (append cider-jack-in-dependencies cider-jack-in-cljs-dependencies))
(let ((cider-jack-in-dependencies (append cider-jack-in-dependencies cider-jack-in-cljs-dependencies))
(cider-jack-in-lein-plugins (append cider-jack-in-lein-plugins cider-jack-in-cljs-lein-plugins))
(cider-jack-in-nrepl-middlewares (append cider-jack-in-nrepl-middlewares cider-jack-in-cljs-nrepl-middlewares))
(orig-buffer (current-buffer)))
Expand Down
54 changes: 0 additions & 54 deletions clojure.sh

This file was deleted.

23 changes: 0 additions & 23 deletions doc/modules/ROOT/pages/config/basic_config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,6 @@ buffers. You can override this behavior, however:
(setq cider-auto-mode nil)
----

== Use `enrich-classpath`

https://github.com/clojure-emacs/enrich-classpath[`enrich-classpath`] is a program/plugin/wrapper that allows CIDER to access to the sources and javadocs of a given project's Java files: your own files, those from your dependencies, and those from the JDK.

With that, CIDER can show better completions, navigation, documentation, stacktrace and Inspector integration.

For Lein users, it has the additional benefit of running a single JVM, instead of the two JVMs that Lein programs typically involve.

NOTE: `enrich-classpath` is still in beta and defaults to being disabled.

You can enable it by setting the `cider-enrich-classpath` defcustom to `t`.

With it enabled, `cider-jack-in` will activate enrich-classpath, given the following conditions:

* You are on macOS/Linux
* You are launching a vanilla JVM repl (and not a cljs repl, or a clj+cljs repl)
* You are using `cider-jack-in` / `cider-jack-in-clj` (and not `cider-connect`)
** For `cider-connect`, please follow enrich-classpath's https://github.com/clojure-emacs/enrich-classpath/tree/v1.19.3#emacs-cider-connect[own instructions].

...these conditions will be progressively relaxed.

It's worth noting that `cider-jack-in` will fall back to the original command if enrich-classpath failed, for whatever reason.

== Prompt for Symbol Confirmation

NOTE: The default here was changed in CIDER 1.0.
Expand Down
21 changes: 5 additions & 16 deletions doc/modules/ROOT/pages/troubleshooting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -295,35 +295,24 @@ Or by customising the jack-in options.

NOTE: Leiningen disables `OmitStackTraceInFastThrow` by default.

=== Errors Related to enrich-classpath

If you get any errors related to `enrich-classpath` when doing `cider-jack-in`, you can disable
the `enrich-classpath` integration like this:

[source,lisp]
----
(setq cider-enrich-classpath nil)
----

=== Navigation to JDK sources doesn't work

Firstly, make sure that you are using enrich-classpath. `cider-enrich-classpath` should be truthy.
If you are launching your own repl process, it should run through enrich-classpath's `lein` wrapper, or `clojure` wrapper.
If you try to navigate to the sources of third-party Java libraries, make sure
that the variable `cider-download-java-sources` is set to `t`.

If you are on Linux and still can't navigate to the source of built-in methods like `.toUpperCase` you
probably haven't installed the JDK sources. While you're at it - it's good to
install the JDK's Javadocs as well. On Debian/Ubuntu:
probably haven't installed the JDK sources. On Debian/Ubuntu:

[source,shell]
----
$ sudo apt install openjdk-17-source openjdk-17-doc
$ sudo apt install openjdk-21-source openjdk-21-doc
----

On Red Hat/Fedora/CentOS:

[source,shell]
----
$ sudo dnf install java-17-openjdk-src java-17-openjdk-javadoc
$ sudo dnf install java-21-openjdk-src java-21-openjdk-javadoc
----

On Guix:
Expand Down
45 changes: 0 additions & 45 deletions lein.sh

This file was deleted.

Loading
Loading