This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-07
Channels
- # announcements (38)
- # asami (14)
- # beginners (35)
- # biff (3)
- # calva (29)
- # cider (20)
- # clj-kondo (7)
- # cljdoc (38)
- # clojure (64)
- # clojure-art (2)
- # clojure-australia (1)
- # clojure-dev (6)
- # clojure-europe (30)
- # clojure-nl (4)
- # clojure-spec (4)
- # clojure-uk (9)
- # clojured (3)
- # clojurescript (87)
- # cursive (17)
- # datahike (2)
- # datomic (10)
- # defnpodcast (2)
- # emacs (2)
- # events (1)
- # fulcro (25)
- # gratitude (1)
- # introduce-yourself (1)
- # jobs-discuss (21)
- # lsp (103)
- # malli (41)
- # meander (8)
- # minecraft (3)
- # missionary (3)
- # nextjournal (20)
- # off-topic (10)
- # pedestal (1)
- # polylith (15)
- # portal (6)
- # releases (2)
- # ring (1)
- # ring-swagger (2)
- # sci (4)
- # shadow-cljs (5)
- # spacemacs (3)
- # sql (11)
- # xtdb (3)
I'm having an issue loading my dependencies. When I user CIDER to connect to a REPL without my :dev
alias everything seems to work fine with the exception of a warning when evaluating server.clj
(source below):
Warning: environ value /Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home for key :java-home has been overwritten with /Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/jre
This appears to be coming from environ
, but I don't know why.
When I activate my :dev
alias my dependencies are no longer found on the classpath:
Syntax error (FileNotFoundException) compiling at (src/zmitchell/cheffy/server.clj:1:1).
Could not locate reitit/ring__init.class, reitit/ring.clj or reitit/ring.cljc on classpath.
This is the command that CIDER is using to jack-in:
/usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0-beta3"} refactor-nrepl/refactor-nrepl {:mvn/version "3.0.0-alpha13"} cider/cider-nrepl {:mvn/version "0.27.2"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:dev:cider/nrepl
This is what my deps.edn
file looks like:
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
ring/ring {:mvn/version "1.8.1"}
integrant/integrant {:mvn/version "0.8.0"}
environ/environ {:mvn/version "1.2.0"}
metosin/reitit {:mvn/version "0.5.2"}
seancorfield/next.jdbc {:mvn/version "1.0.462"}
org.postgresql/postgresql {:mvn/version "42.2.14"}
clj-http/clj-http {:mvn/version "3.10.0"}
ovotech/ring-jwt {:mvn/version "1.2.5"}}
:aliases
{:run-m {:main-opts ["-m" "zmitchell.cheffy.server"]}
:web {:main-opts ["-m" "zmitchell.cheffy.server"]}
:run-x {:ns-default zmitchell.cheffy
:exec-fn greet
:exec-args {:name "Clojure"}}
:build {:deps {io.github.seancorfield/build-clj
{:git/tag "v0.4.0" :git/sha "54e39ae"}}
:ns-default build}
:dev {:extra-paths ["dev"]
:deps {integrant/repl {:mvn/version "0.3.1"}
ring/ring-mock {:mvn/version "0.4.0"}}}
:test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "48c3c67"}}}}}
This is what server.clj
looks like:
(ns zmitchell.cheffy.server
(:require [reitit.ring :as ring]
[ring.adapter.jetty :as jetty]
[integrant.core :as ig]
[environ.core :refer [env]]))
(def app
(ring/ring-handler
(ring/router
["/"
{:get {:handler (fn [req] {:status 200 :body "Hello, World!"})}}])))
(defmethod ig/init-key :server/jetty
[_ {:keys [handler port]}]
(jetty/run-jetty handler {:port port :join? false}))
(defmethod ig/prep-key :server/jetty
[_ config]
(merge config {:port (Integer/parseInt (env :port))}))
(defmethod ig/halt-key! :server/jetty
[_ server]
(.stop server))
(defmethod ig/init-key :cheffy/app
[_ config]
(app config))
(defmethod ig/init-key :db/postgres
[_ config]
(:jdbc-url config))
(defn -main
[config-file]
(let [config (-> config-file
slurp
ig/read-string)]
(-> config
ig/prep
ig/init)))
You have :dev {:deps {}}
but :test {:extra-deps {}}
. Maybe try switching to use extra-deps
?
also, when i run into issues I would just remove CIDER and see if the issue persisted. You should have seen this behavior from just clj -A:dev
i think. The repl also always prints up how it starts the clj and repl and how it starts the cljs repl (when appropriate) so it should remove any semblance of magic. You can try out its commands in a terminal to ensure you get all error messages and then slowly start pulling out tooling.
This fixed it, thank you!
I'm having trouble getting my user.clj
picked up when I load a file in my editor. When I start a REPL with clj -A:dev:test
the functions in user.clj
are available. However, when I start a REPL from Emacs using the jack-in command below, the functions are no longer available:
/usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0-beta3"} refactor-nrepl/refactor-nrepl {:mvn/version "3.0.0-alpha13"} cider/cider-nrepl {:mvn/version "0.27.2"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:dev:test:cider/nrepl
When I say that the functions are no longer available, I mean that when I'm inside a file, say src/zmitchell/cheffy/server.clj
and try to evaluate the (go)
inside (comment (go))
I get an error saying that the symbol go
could not be resolved.
My user.clj
is at dev/user.clj
and I include dev
in the :extra-paths
of the :dev
alias. I've attached some relevant files for troubleshooting.user.clj does not define globally-referred functions. The user
ns is (almost) like any other one, so once you are in the cider REPL, you should make sure that your current ns is user
, not server
Or if you want the repl to stay in namespaces other than user
, use fully-qualified function names (via key bindings, or maybe yasnippets)
Lastly, I think cider/nrepl
is not an alias that CIDER (publicly) defines? I'd recommend using a different name that does not possibly clash with actual cider internals.
Actually the current namespace is user
(according to the REPL prompt). The cider/nrepl
alias is part of the jack-in command that CIDER generates, that's not something I've set on my own.
If I'm editing server.clj
I can call the functions via user/go
, so the functions are loaded. I just can't access without a namespace like I thought I could.
btw, an idiomatic approach for a "Reloaded" workflow would be tweaking cider-ns-refresh-after-fn
and cider-ns-refresh-before-fn
, you can find some recent results on this Slack
@U02CDRYNHDM an example of configuring Cider with lifecycle services https://practical.li/spacemacs/clojure-repl/component-lifecycle.html#configure-cider-refresh-to-use-component-lifecycle

When calling (go) or (reset) I tend to do that from the user
buffer, or have the REPL buffer open and in the user
namespace - especially if logs are sent to the REPL
How can i use cider REPL, on emacs ,to evaluate clojure functions on a .clj
file that isn't associated to a lein project .
cider-load-buffer? https://docs.cider.mx/cider/usage/cider_mode.html