Fork me on GitHub
#cider
<
2022-11-22
>
bhauman18:11:26

hey I’m getting “Are you sure you want to run cider-jack-in without a clojure project?” Looking at the source this seems to only come up if the project-dir can’t be found? Why would the project dir not be found?

bhauman18:11:01

more context: I just updated cider to the latest and this is a new project generated by clj new

dpsutton18:11:14

update clojure-mode. it probably isn’t aware of deps.edn

dpsutton18:11:21

(and ps, great to see you again!)

1
dpsutton18:11:00

(defcustom clojure-build-tool-files
  '("project.clj"      ; Leiningen
    "build.boot"       ; Boot
    "build.gradle"     ; Gradle
    "build.gradle.kts" ; Gradle
    "deps.edn"         ; Clojure CLI (a.k.a. tools.deps)
    "shadow-cljs.edn"  ; shadow-cljs
    )
  "A list of files, which identify a Clojure project's root.
Out-of-the box `clojure-mode' understands lein, boot, gradle,
 shadow-cljs and tools.deps."
  :type '(repeat string)
  :package-version '(clojure-mode . "5.0.0")
  :safe (lambda (value)
          (and (listp value)
               (cl-every 'stringp value))))
if you find this bit in your current clojure-mode it is probably missing deps.edn entry

bhauman19:11:53

And that did it! It’s too bad that clojure-mode didn’t get updated when I updated cider. That was a tough one to solve.

dpsutton19:11:35

luckily there is a great #C0617A8PQ channel for questions before you spend too much time on tooling 🙂

dpsutton19:11:22

its usually pretty quiet in here so any questions are always more welcome

hifumi12319:11:08

M-x straight-pull-all followed by M-x straight-build-all gives me lots of bleeding-edge versions of Emacs Clojure packages, but it's also let me avoid these kind of situations

bhauman19:11:16

So Vscode is really taking over heh?

hifumi12319:11:37

Right now, I'm dealing with a nasty issue with CIDER where dir-local variables do not influence how CIDER injects the enrich-classpath middleware

vemv19:11:44

enrich-classpath author here. LMK if I can help in any way. since Enrich is disabled by default at the moment, knowing about unforeseen interactions would be incredibly helpful :)

hifumi12319:11:17

woah... First of all thanks for the blazing fast response! Secondly, I think the issue is actually with CIDER rather than your awesome library 🙂 Here's how my .dir-locals.el looks like

((nil . ((cider-enrich-classpath . nil)
         (cider-preferred-build-tool . lein))))
When I run M-x cider-jack-in-cljs on my project, CIDER still decides to inject the enrich-classpath middleware. I have it enabled by default but I disable it for CLJS projects since figwheel currently breaks with it. When I explicitly (setq cider-enrich-classpath nil) in e.g. IELM, the problem goes away. So I'm not sure what's really going on here.

🙂 1
vemv19:11:00

Let's say you open a directory with those dir-locals. If you M-: (https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Eval.html) and type cider-enrich-classpath , what is the output? If it evaluates to anything other than nil , basically that's the problem: .dir-locals are are not working as configured

hifumi12319:11:16

Hm... it evaluates to nil yet CIDER invokes lein as follows:

/opt/local/bin/lein update-in :dependencies conj \[nrepl/nrepl\ \"1.0.0\"\] -- update-in :dependencies conj \[cider/piggieback\ \"0.5.2\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.28.7\"\] -- update-in :plugins conj \[mx.cider/enrich-classpath\ \"1.9.0\"\] -- update-in :middleware conj cider.enrich-classpath/middleware -- repl :headless :host localhost

vemv19:11:59

That's pretty weird because cider-enrich-classpath only exists in cider.el, in exactly 3 places: the defcustom declaration and 2 call sites. Those call sites are inside defuns, so they're using whatever value was last set.

vemv19:11:36

Maybe use this pattern:

(advice-add 'the-cider-relevant-function ':around 'my-spy)
where my-spy is a defun that prints the current value of the cider-enrich-classpath defcustom

hifumi12319:11:37

It evaluates to t in the advice function yet when I eval in the buffer it's set to nil.

hifumi12319:11:59

Here's the specific function I added.

(advice-add 'cider-jack-in-cljs :around (lambda (&rest args)
						                  (message (format "%s" cider-enrich-classpath))))

👍 1
vemv19:11:14

hmm... try printing default-directory also. Perhaps it's bound to something other than your project directory and therefore its dir-locals are disregarded? (kind of a crazy hypothesis but also plausible :) )

hifumi12319:11:01

Updated advice function

(advice-add 'cider-jack-in-cljs
             :around (lambda (&rest args)
                       (message (format "%s, %s" default-directory
                                                 cider-enrich-classpath))))
And I get the output ~/Developer/Clojure/project/, t . The default-directory is in the correct directory.

hifumi12319:11:46

Oh I think I know what might be happening. Here's my init.el for CIDER:

(use-package cider
  :commands cider-jack-in
  :config (setq cider-use-tooltips nil
                cider-enrich-classpath t
                cider-lein-parameters "repl :headless :host localhost"))
Maybe CIDER is being lazily loaded by straight.el and it runs the config when I finally invoke a function defined in CIDER?

vemv19:11:24

it does sound very likely :)

hifumi12319:11:40

That looks to be the culprit so far: a freshly restarted Emacs is telling me cider-enrich-classpath is unbound.

hifumi12319:11:59

Removing the :commands bit fixed my issue 😄

vemv19:11:59

yup that's the smoking gun happy you got it! Would be curious about your fix later

vemv19:11:55

I would have guessed that the

cider-enrich-classpath t
bit was the one to be tweaked. Dunno how use-package can dir-locals can interact

👍 1
hifumi12319:11:27

I think the :commands key in use-package makes the package lazily loaded (though you can force it to load with a supplied command). So the situation must've been something like: 1. Emacs starts up, but cider is neither loaded nor configured. 2. dir-locals sets cider-enrich-classpath to nil. 3. cider-jack-in-cljs forces cider to be loaded and configured. 4. cider-enrich-classpath gets set to t

vemv19:11:10

Yes, that makes sense.

hifumi12319:11:47

also IME i see cursive + intellij taking over

cfleming20:11:54

I would love that to be true, but Cursive use has been astonishingly consistent at almost exactly 30% for several years now (according to the community survey).

dpsutton19:11:00

i love emacs and don’t care for text editors that are focused around a project directory. But the beginner experience of vs code is leagues ahead of emacs for sure

hifumi12319:11:23

At my work place, IntelliJ and Emacs is pretty evenly split, then there's that one person using Vim. I've surprisingly not seen VS Code used anywhere, yet... but I do know it's popular in the "outside world", so to speak (e.g. luminus template generates a bunch of vs code specific files for you)

bhauman19:11:41

It’s funny how much time it takes to learn the lesson that if you have a data problem and any DATA problem (code is data, text is data), emacs has a solution.

bhauman19:11:07

I just had to ingest a bunch of information related to passing a citizenship test and emacs of course has org-drill. which has a spaced repetition, flash cardy quizzing functionality

👍 1
vemv19:11:53

today I was about to M-x sort-lines and got to discover M-x solitaire

bhauman19:11:18

Copy and paste the study manual and the a few emacs macros and I’ve got a test in a few hours.

👍 1
bhauman19:11:27

yeah good ol solitaire

dpsutton19:11:09

wow. @bhauman i would love to read an article about that. i don’t have that much emacs-fu but would love to see it

jackrusher07:12:33

@bhauman I'm quite embarrassed to say that I hallucinated the wrong name! 😳 No obituary required!

bhauman17:12:01

Good to know!!! Wish I hadn’t sent that card!

😆 1
bhauman19:11:08

It’s really worth looking into, also learning about incremental reading.

🙏 2
bhauman19:11:16

its on the page

hifumi12319:11:30

Also check out Anki if you want an SRS solution that works outside of Emacs

bhauman19:11:14

I will! Incremental learning is fascinating.