clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.54k stars 645 forks source link

Let CIDER use multi-part commands for all project types. #3187

Open jaccarmac opened 2 years ago

jaccarmac commented 2 years ago

I'm slowly tweaking my Emacs to play nicely with Guix, and after getting SLIME to use Guix packages in a shell I tried to do the same thing in CIDER. Contra SLIME, CIDER doesn't support multi-part values for the likes of cider-clojure-cli-command, and errors out if that variable contains spaces. It also does the check for executable existence even when using a prefix command to manually edit the invocation. It would be nice if CIDER supported guix shell-style versions of the various project type commands, or at least let you do it with a prefix command.

I tweaked cider--resolve-command to use basically the same logic as the shadow-cljs case in cider-jack-in-resolve-command. Is that something which would be reasonable to clean up and submit as a patch?

I'm disinclined to suggest a list format for cider-clojure-cli-command and friends, though the SLIME case shows it's possible. The workaround for the issue without changing CIDER code is to create a stub called clojure somewhere on the path and to use a prefix command to jack in with guix shell.

bbatsov commented 2 years ago

I'm not familiar with guix at all, so I'll need some concrete examples about the nature of the problem and proposed solutions.

jaccarmac commented 2 years ago

Apologies for the assumptions. Guix is a package manager and tool for reproducible builds. guix shell creates one-off environments with certain software installed. So the guix shell lines in my SLIME configuration allow me to boot SLIME on top of various Common Lisp implementations without keeping those implementations installed permanently. guix shell clojure-tools -- clojure is equivalent to clojure, but uses the latest version of Clojure and its dependencies as seen by Guix.

So far, patching CIDER is nice-to-have but not necessary as I could just alias clojure. But Guix also provides a facility for describing a project's dependencies as a Scheme file and creating an environment based on that manifest. So I'd like to C-u M-x cider-jack-in with guix shell -m manifest.scm -- clojure to have a REPL with an isolated, predictable context.

As far as I understand NPX, the Guix workflow I'm in search of is roughly equivalent: Without a defined set of dependencies the latest clojure command is what powers the REPL, but inside a project the REPL starts with that project's context.