This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-12
Channels
- # architecture (17)
- # babashka (13)
- # beginners (12)
- # calva (1)
- # cider (7)
- # clojure-bay-area (15)
- # clojure-europe (4)
- # clojure-norway (7)
- # datomic (7)
- # gratitude (5)
- # honeysql (7)
- # hyperfiddle (2)
- # introduce-yourself (4)
- # jobs-discuss (13)
- # juxt (2)
- # lsp (3)
- # malli (7)
- # practicalli (17)
- # rdf (8)
- # re-frame (9)
- # releases (1)
- # shadow-cljs (24)
- # spacemacs (15)
Hi there! I’m trying to get code lookup for Clojuer Java source to work. Using the Practicalli deps.edn
. I have the Java docs working great (which is super awesome)! I have the clojure source cloned from the repo, and am using emacs with cider-jack-in to connect to the REPL. Here’s what my :src/clojure
alias and my cider-clojure-cli-global-options
look like:
;; in ~./clojure/deps.edn
:src/clojure
{:extra-paths ["src/jvm"]
:extra-deps
{org.clojure/clojure-source {:local/root "/Users/<my-username>/drausen/clojure"}}}
;; from emacs config
(setq cider-clojure-cli-global-options "-A:src/clojure:src/java20:dev/reloaded:portal")
When I jack in, my portal config pops up and I get the success greeting from cider... and no warnings. Java lookup works, but when I try to look up a Java source of Clojure with xref-find-definitions
, I get a “user-error: No definitions found” message.
Any directions or help appreciated! Thank you so much!cider-clojure-cli-aliases
is the correct Cider variable to use to add aliases
The global options variable is depreciated anday have strange side effects
The -A execution flag isn't required (all flags are stripped out by the Cider code)
Hmmm... so with:
(setq cider-clojure-cli-global-options "")
(setq cider-clojure-cli-aliases ":src/clojure:src/java20:dev/reloaded:portal")
It doesn’t seem to be picking up the :src
aliases? And Java lookup also not being found. Jack in nREPL message:
[nREPL] Starting server via /opt/homebrew/bin/clojure -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.0.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.32.0-alpha1\"\}\ refactor-nrepl/refactor-nrepl\ \{\:mvn/version\ \"3.9.0\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[refactor-nrepl.middleware/wrap-refactor\,cider.nrepl/cider-middleware\]\"\]\}\}\} -M:dev/reloaded:cider/nrepl
SPC u
before the jackin key binding will show an editable jack-in command in the mini-buffer
Or start the REPL in a terminal with the Clojure or clj command with the appropriate aliases, then use cider-connect (instead of jack-in) I'll try replicate in the morning. There have been a few changes recently in Cider, so not sure if it's those or something missing in the aliases If you can share a small reproduction repository the demonstrates the issue that would help
All great info, appreciate it! I guess I’m a bit embarrassed to ask, what the best way to start an nrepl-enabled session in another terminal? (I usually just use cider-jack-in to handle all the “magic”.) I did update cider to the latest versions, and pulled the latest practicalli config (updated my :src/clojure to point to my local repo), but still not getting clojure java sources found.
Also, another question: what’s the best way to include java options? I usually also just through those into cider-clojure-cli-global-options
…
My nREPL version and commands:
;; CIDER 1.8.0-snapshot (package:
;; Clojure 1.11.1, Java 20
…
;; Startup: /opt/homebrew/bin/clojure -A:src/clojure:src/java20:dev/reloaded:portal -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.0.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.35.0\"\}\ refactor-nrepl/refactor-nrepl\ \{\:mvn/version\ \"3.9.0\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[refactor-nrepl.middleware/wrap-refactor\,cider.nrepl/cider-middleware\]\"\]\}\}\} -M:cider/nrepl
Practicalli Clojure CLI config has an alias calle :repl/basic
which adds an nrepl server
Run clojure with that alias in the root of the project
clojure -M:repl/basic
Aliases can be chained together
clojure -M:src/clojure:src/java20:repl/basic
JVM options can be added to an alias, e.g
:performance/memory-meter
{:extra-deps {com.clojure-goes-fast/clj-memory-meter {:mvn/version "0.3.0"}}
:jvm-opts ["-Djdk.attach.allowAttachSelf"]}
Or JVM options can be passed on the command line https://practical.li/clojure/reference/jvm/
Agh, this is looking like issues with cider… maybe I should be mentioning this over there… Getting errors on cider-locate-running-nrepl-ports
[:line 1825], where it’s taking the directory-path as argument, inferring the correct port, and returning a list ("my-directory" "51115")
and trying to call directory-file-name
on that list.
I also have a few other REPLs running, so calling cider-locate-running-nrepl-ports
without an argument, returns a list of lists with projects-directories with their nrepl ports. Maybe I try to halt those processes, and try again. Anyways, hopefully feedback useful.
I suggest comment any code or variables that have anything to do with Cider in the Emacs configuration. Also check for.dir-locals.el (although that file only affects. Cider jack-in) Make sure that Cider package is fairly recent, from 2023 at least Then if there are still problems the #C0617A8PQ channel may have more ideas
Ok, the cider folks got back to me, it was certainly an issue that they just recently pushed, so the connection is resolved. The Cider version 1.8.0-snapshot is complaining that it requires cider-nrepl 0.35.0
, but the version in :repl/basic
is using 0.31.0
, so bumping that and seeing if we get a bit further.