jack-in: TRAMP fixes, runtime defaults, tests, docs#3885
Merged
Conversation
`cider-locate-running-nrepl-ports' previously scraped the local machine even when called from a TRAMP buffer, because its `ps' and `lsof' probes went through `shell-command-to-string'. Switch them to `process-file' so they honor `default-directory' and inspect the host the user is actually on. Same fix for the `lsof' health check on `.nrepl-port' files in `nrepl--port-from-file'. Adds two small helpers, `cider--shell-command-to-string' and `cider--process-file-to-string', plus `cider--lsof-fn-field' to dedupe the per-PID lsof parsing.
When jacking in over TRAMP to a server that announces a wildcard or
loopback bind address (e.g. babashka prints `localhost'), CIDER's host
fallback was taking the printed host first, causing connections to land
on the local machine.
Detect wildcard/loopback addresses ("localhost", "127.0.0.1", "0.0.0.0",
"::1", "::") and prefer the TRAMP host when present. Explicit non-
loopback hosts in the server's output are still honored as-is.
`cider-clojure-cli-command' and `cider-jack-in-default' both ran `executable-find' at defcustom evaluation time, so the auto-detected result was frozen at package load. A user who installed Clojure later, or whose PATH changed, had to restart Emacs to get the right default. Make both default to nil and resolve lazily at jack-in time. The clojure-cli tool spec picks up the Windows fallback via a new `:default-command-fn' registry key, evaluated by a small `cider--jack-in-tool-command' helper that the dispatchers share. `cider-project-type' now goes through `cider--effective-jack-in-default' for the same lazy detection. Updates the corresponding `cider-project-type' specs to assert both the explicit-override and auto-detect paths.
`cider--update-project-dir' was reusing one fixed-name hidden buffer (\" *cider-context-buffer*\") across all invocations, killing whatever content was there at the start of each call. Two interleaved or interrupted jack-ins could corrupt each other's context (dir-local variables, transferred buffer-locals). Use `generate-new-buffer' for a unique name per invocation. The buffers are hidden and small; we let Emacs reclaim them once no longer referenced.
Cover the registry-driven dispatch that landed in #3884: - Each built-in tool has the expected :command-var, :params-var, and :project-files keys. - `cider--jack-in-tool' signals user-error for an unknown project type. - `cider-register-jack-in-tool' adds and replaces entries. - `cider-inject-jack-in-dependencies' is a no-op for babashka, nbb, basilisp, and prepends -d flags for shadow-cljs. - `cider-jack-in-universal' dispatches by :universal-prefix-arg to the right entry point (clj vs cljs), errors on unknown args, and falls back to `completing-read' when called with nil outside a project. - `cider--identify-buildtools-present' iterates the registry's :project-files entries.
Several before-each blocks in cider-tests.el used `setq-local' on dynamic vars that were not in their describe's `:var' list. Buttercup's per-spec rebinding only covers `:var', so the buffer-local writes survived past the `it' boundary and silently weakened later assertions. This is the FIXME at the former line 191. Replace `setq-local' with plain `setq' inside those before-each blocks and extend each describe's `:var' to cover every var being rebound. The two remaining `setq-local' calls (in the shadow-cljs-init-form spec) are inside `with-temp-buffer' and are scoped correctly.
- Rewrite the universal jack-in section in up_and_running.adoc to describe `cider-jack-in-tools' and `cider-register-jack-in-tool' (`cider-jack-in-universal-options' is gone since #3884). - New "Overriding the jack-in command per buffer" subsection covering `cider-jack-in-cmd' as the right escape hatch for containers, TRAMP, and wrapper scripts. - New "Known TRAMP caveats" subsection: executable resolution, endpoint discovery, loopback bind addresses, cross-OS quoting. - Fix a stale claim that `cider-jack-in-default' defaults to `clj'. - `cider-enable-nrepl-jvmti-agent' docstring now spells out the Java 21 eval-interrupt context that motivates it. - CHANGELOG entries for the TRAMP and runtime-default bug fixes from the preceding commits.
94e500c to
0ef9253
Compare
This was referenced Apr 28, 2026
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Final round of cleanup after #3883 (entry-point unification) and #3884 (registry refactor).
TRAMP / robustness
cider-locate-running-nrepl-portsnow drives itsps/lsofprobes throughprocess-file, so endpoint completion forcider-connectqueries the remote host when called from a TRAMP buffer instead of always scraping the local machine. Same change for thelsofhealth check on.nrepl-portfiles innrepl-client.el.cider-clojure-cli-commandandcider-jack-in-defaultno longer freeze their auto-detection at package load. Both default tonilnow, with the auto-detect logic running at jack-in time. Installing Clojure later, or putting it onPATH, doesn't require restarting Emacs. The clojure-cli tool spec gets the fallback via a new:default-command-fnregistry key.cider--update-project-dirstops reusing a single shared*cider-context-buffer*. Each invocation creates a unique hidden buffer, so concurrent or interrupted jack-ins don't corrupt each other's state.nrepl-server-filter's host fallback now treats wildcard/loopback addresses (localhost,127.0.0.1,0.0.0.0,::1,::) printed by the server as "use the calling context", so a jack-in over TRAMP to e.g. babashka -- which announceslocalhost-- connects to the TRAMP host instead of the local machine. Explicit non-loopback hosts in the server's output are still honored as-is.Tests
cider-register-jack-in-tooladd/replace semantics, the no-op injectors (babashka, nbb, basilisp), shadow-cljs-dinjection,cider-jack-in-universalprefix-arg dispatch (clj, cljs, unknown arg, completing-read fallback), andcider--identify-buildtools-presentiterating the registry.cider-tests.el:191: the existing jack-in describe blocks were usingsetq-localto override dynamic vars, which leaked into later specs. Replaced with plainsetqand extended each block's:varlist so Buttercup's per-spec rebinding actually scopes them.Docs
cider-jack-in-toolsandcider-register-jack-in-tool(the variable from Introduce a jack-in tool registry #3884 replacedcider-jack-in-universal-options).cider-jack-in-cmd-- the right escape hatch for containers/TRAMP/wrapper scripts.cider-jack-in-defaultdefaulting toclj.cider-enable-nrepl-jvmti-agentdocstring now spells out the Java 21 eval-interrupt context.Verified
eldev compileclean.eldev test: 519/522 specs pass, 0 failures, 3 skipped (platform/version-gated; same as master).