Fork me on GitHub
#cider
<
2022-11-26
>
johnny.martin05:11:30

I am doing something wrong and am stuck. I get an odd error when evaluating the following two lines GNU Emacs after a cider-jack-in. (s/def ::thing number?) (s/gen ::thing)

1. Unhandled java.io.FileNotFoundException
   Could not locate clojure/test/check/generators__init.class,
   clojure/test/check/generators.clj or
   clojure/test/check/generators.cljc on classpath.
These work just fine when I do, clj from the command line, but fail inside my GNU Emacs Cider session. Thinking (wrongly perhaps) Cider wanted to use test.check, I followed this link, https://search.maven.org/artifact/org.clojure/test.check, guessed the correct, latest version, is 1.1.1 and so I included this line in my deps.edn, org.clojure/test.check {:mvn/version "1.1.1"} In my spec source files i also commented out the clojure.spec.gen.alpha and instead include test.check namespace declarations, (:require [clojure.spec.alpha :as s] ; [clojure.spec.gen.alpha :as gen] [clojure.test.check :as tc] [clojure.test.check.generators :as gen] ... Still, the Cider REPL grumbles with the same error about not finding test.check's missing namespace. (Again in contrast this works just find when I start a REPL from the command line). Where am I going wrong? Does Cider need to be told to do dynamic class loading or something?

dpsutton06:11:50

when you say a bare clj repl, how are you actually starting that repl?

dpsutton06:11:40

because you cannot generate things using s/gen without org.clojure/test.check on your classpath

dpsutton06:11:48

there's nothing specific to CIDER at play here

jumar07:11:39

You may invoke cider-jack-in with the prefix (C-u) and then it lets you see and customize the run command. You can try to run the same command from the shell and see what happens

johnny.martin07:11:01

When I run clj at the command line, i get this:

(require '[clojure.test.check.generators :as gen])
nil
(gen/sample (s/gen ::thing))
(0.5 0 0 -0.875 -2.5 0 -1.65625 -5 0.25 -1)
But then inside cider i get
Unhandled java.io.FileNotFoundException
   Could not locate clojure/test/check/generators__init.class,
   clojure/test/check/generators.clj or
   clojure/test/check/generators.cljc on classpath.

johnny.martin07:11:10

When I do C-u cider-jack-in, i see the jack-in command is, /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"} cider/cider-nrepl {:mvn/version "0.28.5"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"} cider/cider-nrepl {:mvn/version "0.28.5"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl

johnny.martin07:11:12

Sorry, cut-paste twice... that should be,`/usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"} cider/cider-nrepl {:mvn/version "0.28.5"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl`

johnny.martin07:11:38

Ok, now i am most confused... I enter the command, /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"} cider/cider-nrepl {:mvn/version "0.28.5"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl at the command line and do a cider-connect instead of cider-jack-in and it works!

johnny.martin07:11:10

@U06BE1L6T and @U11BV7MTK Thank you for your prompt replies! I must have had some stale buffer or something left over cruft in deps.edn file that I missed. Something that has now mysteriously dissapeared. Sorry for bugging you all with this. For some curious reason now all is working as expected. I must humbly admit to stupid programmer error on my part. Again thank you both for your prompt replies!

jumar08:11:21

No problem- great that you solved it!

vlnn16:11:24

I have a question on formatting maps and key alignments. Let’s say I have a set of maps aligned like that.

(def map-to-format
  #{{:ones "1"      :twos "22222"  :threes "3333333333"}
    {:ones "11"     :twos "22"     :threes "3333333333"}
    {:ones "111"    :twos "2"      :threes "3333333333"}
    {:ones "1111"   :twos "22222"  :threes "3333333333"}
    {:ones "111111" :twos "22222"  :threes "3333333333"}})
Cider reformats it to
(def map-to-format
  #{{:ones "1" :twos "22222" :threes "3333333333"}
    {:ones "11" :twos "22" :threes "3333333333"}
    {:ones "111" :twos "2" :threes "3333333333"}
    {:ones "1111" :twos "22222" :threes "3333333333"}
    {:ones "111111" :twos "22222" :threes "3333333333"}})
Where can I disable this behavior or make some custom rules? UPD: maybe there’s a possibiliy to mark sexps so they are skipped while formatting the buffer?

rolt16:12:53

a bit late but cider can use cljfmt: https://github.com/clojure-emacs/cider/blob/b11991245f6fb6e183757da66f47cc5d04221ae1/doc/modules/ROOT/pages/usage/misc_features.adoc#formatting-code-with-cljfmt If you want a really customizable experience, I'd recommend dropping cider indentation and using zprint instead

1
vlnn03:12:16

Thanks, will try that!

Apple21:11:02

http://paredit.org/cgit/paredit/commit/?h=maint-25&amp;id=5615023023aea50683f5725284fb9bc6cbbd64ec paredit 25 breaks cider repl. repl buffer no longer works. repl still works.

1
Volodymyr Anokhin02:11:07

Have you check 26th?

Apple03:11:27

same thing

😬 1
Derek16:11:59

Can reproduce. RET doesn’t send forms to the REPL, but C-RET still does.

Derek16:11:25

I believe RET was previously unbound by paredit so it would be bound to cider-repl-return but now it’s bound to paredit-RET

Derek16:11:36

I unbound “RET” from the paredit-mode-map and all works in CIDER again

👍 2
Apple16:11:33

Good to know C-RET works.

ghadi15:11:03

btw how do you unbind "RET" @UPEKQ7589?

Derek15:11:49

I’m using leaf.el, but I believe whichever mechanism you use, you bind it to nil

norman20:12:09

for use-package:

(use-package paredit
  :bind  (:map paredit-mode-map
          ("RET" . nil))
  :init
  (add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode))

👍 1
dpsutton17:01:59

just seeing this now. I think that still leaves you at the mercy of other modes deciding what RET might do. I always did this

(use-package cider
  :demand t
  :load-path "~/projects/dev/cider/"
  :init
  (load "cider-autoloads" t t)
  :config
  (setq cider-invert-insert-eval-p t)
  (setq cider-switch-to-repl-on-insert nil)
  (setq cider-auto-select-test-report-buffer nil)
  (setq cider-font-lock-dynamically t)
  (setq cider-show-error-buffer nil)
  (setq cider-repl-display-help-banner nil)
  (setq cider-repl-pop-to-buffer-on-connect 'display-only)
  (setq cider-repl-tab-command (lambda () (company-indent-or-complete-common nil)))
  :bind (:map
         cider-repl-mode-map
         ("RET" . cider-repl-newline-and-indent)
         ("C-j" . cider-repl-return)
         ("C-c SPC" . clojure-align)
         ;; :map
         ;; paredit-mode-map
         ;; ("C-j" . cider-repl-return)
         ))
makes sure that "RET" adds a newline, C-j sends the repl input. Looks like i hacked around paredit at some point?

👍 2