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?Are you sure that custom shell aliases aren't involved?
you are expecting the alias :foo-dev to be applied to a local root dep?
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
@dpsutton I'm probably trying to combine too many shortcuts. I'll just break out that code into a project...
That said, I do have aliases in deps.edn and use them regularly, specifically the one to load cider.
And several other dev tools
Right now, bhaumann's clojure-mcp is one of them.
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
Ah ok
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
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.
So far it haven't caused problems like TS experiences, so it's probably something else going on.
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
@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.
You can have several aliases with :local/root stuff and completely separated src folders (and they don't have to be named , so I think the solution is along that way.src verbatim)
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.
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]"]}
Then, you start the repl with clojure -M:cider and it will work
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/"}}}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.
You can do that, or start a cider-sprinkled nrepl on a different port altogether.
Or jack-in via your editor where it should add both nREPL and CIDER etc...?
My colleague does that, but I prefer to start from command line and just 'connect'
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.
Makes sense...
I start my REPL like this: clojure -J-Djdk.attach.allowAttachSelf -M:1.12:portal:test:cider-nrepl:rebel:dev/repl
Why not move -J-Djdk.attach.allowAttachSelf to one of the aliases? Or a new alias.
That's actually what I did, and just stack it with the other aliases.
i do clj -M:"$ALIASES"
I do cl and then cursor up 😉
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...
https://github.com/seancorfield/dot-clojure/commit/becf98ad3bc063de560d1d172e28f0872d21535b 🙂
i just noticed this on the http://clojure.org reader reference. i don't think any non-official dialects have done this lol
babashka uses :bb, clojuredart uses :cljd, jank uses :jank, basilisp uses :lpy, joker uses :joker
it seems strange to me to have statements like this that won't ever be enforced
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 🙂
My take is that it is a generic warning so that if an official ... yup, exactly what @mario.giampietri said.
Nbb has done so
The wording is clever, almost poetic. It makes the guidance more-or-less clear, but meanwhile the glaringly meaningless word "official" leaves options open.