clojure

jmckitrick 2025-07-15T17:02:07.463709Z

I'm having a minor config issue with deps.edn. In my personal folder:

.clojure/
- deps.edn
- src/
-- user.clj
-- foo/
--- custom_stuff.clj
I have a :user alias with :extra-deps for CIDER and an entry global/user-clj with :local/root pointing to ~/.clojure , so it will pick up my user.clj and start CIDER. This works fine. I have a NEW non-working alias :foo-dev with :extra-paths pointing to ["src"] and then :exec-fn calling foo.custom-stuff/bar . When I run clojure -X:foo in my home folder, I get this: Namespace could not be found on classpath: foo.custom-stuff But if I cd to .clojure and run it there, it finds the foo.custom-stuff class, but it also includes and runs the unwanted code in user.clj and attempts to start CIDER. So... in my home folder, it doesn't build the correct classpath, but in the correct classpath folder, it includes unwanted code files. What am I doing wrong?

oyakushev 2025-07-15T17:07:59.700869Z

Are you sure that custom shell aliases aren't involved?

dpsutton 2025-07-15T17:10:26.592169Z

you are expecting the alias :foo-dev to be applied to a local root dep?

dpsutton 2025-07-15T17:12:24.660099Z

a few things going on. user.clj is loaded if on the classpath. it’s a foot gun and probably doing stuff you don’t want to do. reusing .clojure as a project is really weird. you are combining lots of stuff. make some regular folder that you include. don’t name a top level namespace user.clj unless you explicitly expect and desire that to be loaded very early and non-deterministically. You also cannot send aliases to deps. the alias must operate on the top level project. i think this is a requested feature and one actively being worked on now though

jmckitrick 2025-07-15T17:16:40.093759Z

@dpsutton I'm probably trying to combine too many shortcuts. I'll just break out that code into a project...

jmckitrick 2025-07-15T17:17:17.230229Z

That said, I do have aliases in deps.edn and use them regularly, specifically the one to load cider.

jmckitrick 2025-07-15T17:17:40.288169Z

And several other dev tools

jmckitrick 2025-07-15T17:18:04.678819Z

Right now, bhaumann's clojure-mcp is one of them.

dpsutton 2025-07-15T17:18:26.236419Z

Yes it’s totally made for that purpose. Definite aliases in there. Don’t turn it into a project that it itself needs aliases applied to itself

jmckitrick 2025-07-15T17:18:43.002459Z

Ah ok

dpsutton 2025-07-15T17:20:10.495519Z

and there is no notion of {:deps {something-local {:local/root "/Users/me/project" :aliases [:foo-dev]}}}. that’s the point i’m trying to make. you cannot (yet) send aliases down to things you depend on

oyakushev 2025-07-15T17:20:41.305359Z

Global user.clj is a trick I suggest here https://clojure-goes-fast.com/blog/system-wide-user-clj/, it works for me pretty well.

oyakushev 2025-07-15T17:21:46.917199Z

So far it haven't caused problems like TS experiences, so it's probably something else going on.

dpsutton 2025-07-15T17:22:04.041249Z

gotcha. it can be handy. i’ve just seen tons of people caught out during aot. i personally think just a single segment namespace that you load is just as good with less footgun. (require 'dev) type thing

👍 1
jmckitrick 2025-07-15T17:22:22.864859Z

@alexyakushev Yes, that's exactly the setup I'm using. And I was trying to apply another suggestion to set up a custom mcp server, but I conflated it into the same folder (trying to make it universally usable by clojure -X:mcp-dev ) but that's apparently a mistake.

oyakushev 2025-07-15T17:23:34.775029Z

You can have several aliases with :local/root stuff and completely separated src folders (and they don't have to be named src verbatim), so I think the solution is along that way.

jmckitrick 2025-07-15T17:26:19.238829Z

I started this whole adventure because my (non-cider) colleagues kicked my cider setup out of the project, so I had to find my own way to include it w/o changing the project source code.

oyakushev 2025-07-15T17:27:30.254239Z

For that you don't need the whole user.clj magic. For example, here's how my :cider alias looks like in the global deps.edn:

:cider {:extra-deps
        {nrepl/nrepl {:mvn/version "1.3.1"}
         cider/cider-nrepl {:mvn/version "LATEST"}
         refactor-nrepl/refactor-nrepl {:mvn/version "3.9.0"}}
        :main-opts ["-m" "nrepl.cmdline" "-i"
                    "--middleware" "[cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor]"]}

oyakushev 2025-07-15T17:27:52.338979Z

Then, you start the repl with clojure -M:cider and it will work

dpsutton 2025-07-15T17:28:13.865739Z

i have lots of this in my deps.edn:

:grepl      {:extra-deps {grepl/grepl {:local/root "/Users/dan/projects/clojure/grepl"}}}

           :tools      {:extra-deps {org.clojure/tools.trace {:mvn/version "0.8.0"}
                                     criterium/criterium     {:mvn/version "0.4.6"}
                                     io.github.nubank/morse  {:git/tag "v2023.04.30.01" :git/sha "d99b09c"}
                                     grepl/grepl             {:local/root "/Users/dan/projects/clojure/grepl"}}}
           ;; MCP server configuration (for reference)
           :mcp {:extra-deps {org.slf4j/slf4j-nop {:mvn/version "2.0.16"}
                              clojure-mcp/clojure-mcp
                              {:local/root "/Users/dan/projects/clojure/clojure-mcp/"}}
                 :exec-fn clojure-mcp.main/start-mcp-server
                 :exec-args {:port 7888}}
           :duckdb     {:jvm-opts ["-Dmb.dev.additional.driver.manifest.paths=/Users/dan/projects/work/metabase_duckdb_driver/resources/metabase-plugin.yaml"]
                        :extra-paths ["/Users/dan/projects/work/metabase_duckdb_driver/test"]
                        :extra-deps
                        {duckdb/metabase-driver
                         {:local/root "/Users/dan/projects/work/metabase_duckdb_driver/"}}}

jmckitrick 2025-07-15T17:28:50.676679Z

Well, our project already starts nrepl, and I just have another one-liner to promote that to a cider-nrepl connection, since I prefer to start the project independently of emacs and/or cider.

oyakushev 2025-07-15T17:30:11.313129Z

You can do that, or start a cider-sprinkled nrepl on a different port altogether.

seancorfield 2025-07-15T17:55:29.083199Z

Or jack-in via your editor where it should add both nREPL and CIDER etc...?

jmckitrick 2025-07-15T17:56:25.188599Z

My colleague does that, but I prefer to start from command line and just 'connect'

seancorfield 2025-07-15T17:57:03.409669Z

My .config/clojure folder is here https://github.com/seancorfield/dot-clojure and, yes, it is a project as well, but the :dev/repl alias refers to it via a git dep rather than :local/root since I have it published.

jmckitrick 2025-07-15T17:58:10.622399Z

Makes sense...

seancorfield 2025-07-15T17:58:45.934889Z

I start my REPL like this: clojure -J-Djdk.attach.allowAttachSelf -M:1.12:portal:test:cider-nrepl:rebel:dev/repl

p-himik 2025-07-15T18:16:03.534019Z

Why not move -J-Djdk.attach.allowAttachSelf to one of the aliases? Or a new alias.

➕ 1
jmckitrick 2025-07-15T18:31:16.956299Z

That's actually what I did, and just stack it with the other aliases.

dpsutton 2025-07-15T18:50:33.979359Z

i do clj -M:"$ALIASES"

jmckitrick 2025-07-15T19:11:00.194609Z

I do cl and then cursor up 😉

seancorfield 2025-07-15T19:16:16.815909Z

True, I could do that @p-himik... I originally added it at work to a specific clojure invocation to test it and then I copy-pasta'd it into two other places at work and then into my user repl script 🙂 I can clean that up...

2025-07-15T18:36:04.498199Z

i just noticed this on the http://clojure.org reader reference. i don't think any non-official dialects have done this lol

2025-07-15T18:39:59.726189Z

babashka uses :bb, clojuredart uses :cljd, jank uses :jank, basilisp uses :lpy, joker uses :joker

2025-07-15T19:13:32.646379Z

it seems strange to me to have statements like this that won't ever be enforced

Mario G 2025-07-15T19:29:38.107999Z

Well, in the (unlikely) case the owners of an official platform decide they really badly need and want one of those unqualified keywords, they'll be free to say we told/warned ya 🙂

seancorfield 2025-07-15T19:29:56.254579Z

My take is that it is a generic warning so that if an official ... yup, exactly what @mario.giampietri said.

borkdude 2025-07-15T20:41:54.443569Z

Nbb has done so

2025-07-15T23:20:57.675039Z

The wording is clever, almost poetic. It makes the guidance more-or-less clear, but meanwhile the glaringly meaningless word "official" leaves options open.