This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-26
Channels
- # babashka (5)
- # beginners (21)
- # cider (26)
- # clojure (46)
- # clojure-art (3)
- # clojure-dev (36)
- # clojure-europe (24)
- # clojure-norway (64)
- # conjure (28)
- # cursive (2)
- # datomic (1)
- # honeysql (12)
- # improve-getting-started (5)
- # introduce-yourself (5)
- # kaocha (1)
- # malli (17)
- # polylith (36)
- # reitit (3)
- # shadow-cljs (8)
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?because you cannot generate things using s/gen
without org.clojure/test.check
on your classpath
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
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.
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
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`
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!
@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!
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?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
http://paredit.org/cgit/paredit/commit/?h=maint-25&id=5615023023aea50683f5725284fb9bc6cbbd64ec paredit 25 breaks cider repl. repl buffer no longer works. repl still works.
Have you check 26th?
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
btw how do you unbind "RET" @UPEKQ7589?
for use-package:
(use-package paredit
:bind (:map paredit-mode-map
("RET" . nil))
:init
(add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode))
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?