Fork me on GitHub
#tools-deps
<
2020-12-27
>
vemv11:12:30

Curious, can one configure clj to run some code as soon as a REPL is fired up? Basically an equivalent to Lein's :init option

delaguardo11:12:57

clj -M -e '(some-code)' -r

vemv11:12:47

Nice! Thanks to your answer I checked out https://github.com/practicalli/clojure-deps-edn/blob/65a48e1547d289a3d647d9f32bf3d2cc7fe8d5d3/deps.edn#L479 I wish though that those humongous strings could be expressed as nicely formatted sexprs instead

vlaaad15:12:38

This can be expressed as a 5 lines of code in a file that is executed by clj

vlaaad15:12:07

Ah, it was already mentioned in later discussion

delaguardo11:12:52

you can make a function for that somewhere in sourcepath

delaguardo12:12:54

in one of my projects I have dev/src/dev/utils.clj file with (ns dev.utils) I also add :extra-paths ["dev/src"] to one of my alias for dev environment in that namespace you can create a function and then from console run it using requiring-resolve

vemv12:12:29

Ah nice! Similarly, my -e could be a single require and I do all the work in a proper .clj file That way I'd skip the last step you describe

delaguardo12:12:29

clj -A:dev -M -e '((requiring-resolve 'dev/init))' -r that’s how it could look like in cli

👍 3
delaguardo12:12:23

and you can also use -i path to specify namespace to load as init

🙌 3
Alex Miller (Clojure team)14:12:00

Or use -i instead of -e

Alex Miller (Clojure team)14:12:37

Oh sorry, slack didn’t show me the last message there :)

seancorfield00:12:20

https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L93 shows how to load a dev.clj script from from your .clojure folder (I know this won't work with XDG systems) so you can have a dev script for all your projects, without needing code in every project.

3
seancorfield00:12:00

(I should probably rename that so it doesn't conflict with any :dev alias someone actually has in a project deps.edn file)

Santiago15:12:27

How can I access my project’s version at runtime? I’m using deps.edn

borkdude16:12:19

@slack.jcpsantiago does deps.edn have version numbers?

Santiago16:12:03

@borkdude Mine straight from clj-new doesn’t and it seems it’s not supposed to? There is a version in pom.xml <version>0.1.0-SNAPSHOT</version> , so I could read this file. I was looking for something that would work like environ and would read this automatically

practicalli-johnny23:12:17

@slack.jcpsantiago if using environ the set an Environment variable or create a .properties file for a Java system property

borkdude23:12:51

I just inspected clojure.basis to see if my jvm-opts propagated correctly when composing aliases. It did. Neat.

borkdude23:12:32

Btw, I stumbled upon this blog https://insideclojure.org/2020/07/28/clj-exec/ but it seems the arguments have been renamed from :fn and :args to :exec-fn and :exec-args?

borkdude23:12:43

Maybe update the blog or is it immutable?

seancorfield23:12:16

That blog is a great example of the history of Clojure features and how they evolve during prerelease work. Changing past posts would remove that evolution.

Alex Miller (Clojure team)23:12:13

“Don’t believe everything you read on the internet” - Lincoln

andy.fingerhut23:12:24

It would make sense to add a footnote to an older blog post with a reference to a later update, if one was so inclined.

Alex Miller (Clojure team)23:12:29

Well, I’m on vacation :)

andy.fingerhut23:12:58

Sorry, I should have mentioned that I'm not trying to nudge you or anyone to do that. I do agree that leaving older posts unchanged (except perhaps by addition of such forward-reference footnotes) makes a lot of sense, for anyone wanting to see the history.

seancorfield00:12:20

https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L93 shows how to load a dev.clj script from from your .clojure folder (I know this won't work with XDG systems) so you can have a dev script for all your projects, without needing code in every project.

3