Fork me on GitHub
#cider
<
2021-12-07
>
jumar06:12:44

REPL started from a deps.edn file containing this definition for :jvm-opts doesn't seem to pickup the options - is this :cider/nrepl alias the correct way to pass them?

...
 :aliases
 {:cider/nrepl
  {:jvm-opts ["-Djdk.attach.allowAttachSelf=true"
...

vemv06:12:30

From what I remember from a GH issue, :cider/nrepl is internal / not an API; instead you should define your own alias and make cider use it via a related defcustom

jumar07:12:10

I'm struggling to set it to proper value via customizer-variable - what is the proper syntax? I tried dev, dev:, '("dev") , etc. but nothing seems to work

vemv07:12:03

I know of a codebase that uses this (cider-clojure-cli-global-options . "-A:dev:test") (note it's a different defcustom)

jumar07:12:34

Here I've found a newer information: https://practical.li/spacemacs/clojure-projects/project-configuration.html Ended up with this in .dir-locals.el:

((clojure-mode . ((cider-preferred-build-tool          . clojure-cli)
                  (cider-clojure-cli-aliases           . ":dev"))))
I couldn't make it work via customize-variable gui

dpsutton13:12:45

You don't need that leading semi colon. Also, you only need to specify the preferred build tool if there are multiple tooling files (shadow-cljs.edn or project.clj files at the root as well)

practicalli-johnny14:12:48

Not using a leading colon is confusing, as it’s not the name of the alias. I always include the colon so it’s consistent with the normal use. It seems cider adds an extra colon after the -M flag for some reason, but it still works

dpsutton14:12:40

ah right. good call

dpsutton14:12:05

it adds an extra colon?

practicalli-johnny15:12:42

When I use an alias, for example ":dev:test" , as the cider-clojure-cli-aliases value, then in the command line that Cider generates when calling cider-jack-in-clj, that command ends with -M::dev:test:cider-nrepl I assume it works because the missing alias, the first colon by itself : , doesnt match anything, so is just ignored by the clojure command line program

practicalli-johnny15:12:09

I noticed this when I was editing the command before executing, using C-u (or SPC-u in spacemacs) On my project at work I get the same result. This is the command from the buffer window after running cider-jack-in-cljs with a .dir-locals.el set to include ":env/develop:env/test"

Starting new CIDER session ...
[nREPL] Starting server via /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0-beta5"} cider/cider-nrepl {:mvn/version "0.27.2"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}' -M::env/develop:env/test:cider/nrepl
[nREPL] server started on 34825
[nREPL] Establishing direct connection to localhost:34825 ...
[nREPL] Direct connection to localhost:34825 established
1

dpsutton15:12:45

i see. the string functions could use a little cleanup then. It does some trimming and needs to be updated to allow for a leading : on the cli aliases

diego.videco16:12:55

I want to add cemerick.pomegranate as a dev dependency (only for me) on a tools.deps project. What is the best way to go about it?

dpsutton17:12:07

throw that dep in an alias in your ~/.clojure/deps.edn and add that when you jack in. you can manually edit the jack-in string with a prefix arg, or use dir locals in that project

((nil
  (cider-clojure-cli-aliases . "pomegranate")))
or whatever you name the alias. that requires adding the dir-local to the repo, not sure if that’s already taken. another option is just to copy the startup command from the repl buffer at the top and then start it yourself on the command line with whatever aliases you want. This is the most straightforward way i think

dpsutton17:12:39

if you copy the alias the CIDER creates in-line with -Sdeps you can throw that into your /.clojure/deps.edn and then any project you can easily start up with clj -M:my-aliases:cider/nrepl and your startup will be always easy~ simple. And you can then just cider-connect

vemv01:12:44

there's dir-locals2 which can be gitignored

👍 2
winsome23:12:24

what's the setting to make the repl not open a new window after cider-jack-in?

fedreg23:12:54

This?

(setq cider-repl-pop-to-buffer-on-connect  nil)

1