Fork me on GitHub
#tools-deps
<
2022-08-27
>
armed17:08:32

Hello, I’m a bit confused. I’ve a ~/.clojure/deps.edn with a few aliases. If I cd to ~/.clojure and run clj -A:portal -Stree it finds :portal alias and prints all dependencies. However in all other directories clj does not find :portal alias and prints WARNING: Specified aliases are undeclared and are not being used: [:portal]. What I’m missing here? Using latest clojure version 1.11.1.1155 on macos.

armed17:08:04

Ok, clojure cli lookups for $CLJ_CONFIG first, then $XDG_CONFIG_HOME and fallbacks to $HOME/.clojure. Recently I defined XDG_CONFIG_HOME for another tool to work. So that broke clojure’s search path. Fixed by defining $CLJ_CONFIG

seancorfield22:08:59

Or move that to ~/.config/clojure/deps.edn so it's XDG-compliant?

👍 1
practicalli-johnny10:08:34

I agree with Sean that .config/clojure is a more discoverable place I also moved all my Clojure dev tooling to XDG specification https://practical.li/blog/posts/adopt-FreeDesktop.org-XDG-standard-for-configuration-files/

Chase17:08:33

In my -main function I am using print and was seeing the expected output in the terminal when running clj -M -m practice.core but not when building and running the uberjar with java -jar ... . In looking at the print docs I figured I needed to add a call to flush and sure enough that fixed it. I had read that using the clj -M -m method of running a program is equivalent to using java -jar so I'm curious if there are other small gotchas like this.

hiredman18:08:43

It is just not true that they are equivalent

Chase18:08:53

That's what I figured. Tbf, I think that conversation was more in the line of starting a backend server. Maybe they meant in that specific instance you could use either or.

Alex Miller (Clojure team)20:08:22

You would need to share more of your code and uberjar to really say more

Chase22:08:47

Eh, it's just my little practice repo. Nothing really going on there. More a curiosity than a problem. https://github.com/Chase-Lambert/clojure-practice/blob/main/src/practice/core.clj

Alex Miller (Clojure team)23:08:57

when build the uberjar, are you setting practice.core as the Main-Class ?

Chase00:08:27

Yep. The code works. I was just curious about the difference between clj -M -m ... and java -jar ... as the former worked without calling (flush) and the latter did not. I am wondering what other differences there are because they are running the same function.

hiredman00:08:58

-M goes through there, which has a call to flush in a finally

Chase00:08:25

Ahh, yep, that explains it. Cool. Thanks for sharing that

hiredman00:08:55

It also sets up a bunch of bindings which aot'ing your own entry point won't have

Chase00:08:15

It's cool how readable the clojure source is. I imagined a ton of wild optimizations but even though some of this is over my head it seems quite approachable to me.

Alex Miller (Clojure team)04:08:01

The repl is really just calls to read eval print in a loop. So not much magic