Fork me on GitHub
#tools-deps
<
2019-05-28
>
thheller09:05:21

@alexmiller I think a shadow-cljs user stumbled into a bug in tools.deps regarding :exclusions of libs. not sure if intentional.

thheller09:05:30

{:deps
 {org.clojure/clojure {:mvn/version "1.10.0"}
  thheller/shadow-cljs {:mvn/version "2.8.37"}
  io.pedestal/pedestal.service {:mvn/version "0.5.5"}
  }}

thheller09:05:59

shadow-cljs has a dependency on ring-core but excludes clj-time

thheller09:05:00

[ring/ring-core "1.7.1"
    :exclusions
    ;; used by cookie middleware which we don't use
    [clj-time]]

thheller09:05:46

pedestal.service also depends on ring-core but the exclusion from shadow-cljs is applied to its dep

thheller09:05:51

so clj-time is missing

rickmoynihan10:05:53

Do any of the tools-deps tools for generating an uberjar have support for something like lein’s :uberjar-merge-with?

dominicm10:05:28

Pack avoids conflicts altogether with a classloader.

rickmoynihan10:05:53

The thing is, I need to merge edn files

rickmoynihan10:05:41

e.g. data_readers.edn but in particular duct_hierarchy.edn

rickmoynihan11:05:51

ok actually avoiding the conflicts and using a classloader would probably work… I guess I can just walk the resources and merge them myself. Which of the uberjar options will use a classloader? I’m guessing capsule?

rickmoynihan11:05:53

hmmm… infact I probably don’t need to merge them myself… duct must be doing this already to work at the repl.

rickmoynihan11:05:23

ok I can confirm pack.alpha capsule just works ™️ thanks

rickmoynihan11:05:49

also capsule is awesome 😀

dominicm12:05:48

Capsule is very cool :)

dominicm12:05:52

Pack currently has a no conflict policy so that you don't have an option to shoot yourself in that respect.

rickmoynihan13:05:09

:thumbsup: a good policy to have

rickmoynihan13:05:02

what is the purpose of -e in pack.alpha? Why not just an alias with the extra-paths there? Or is it different somehow?

rickmoynihan13:05:32

Is there any extra meaning in > Add directory to classpath for building

dominicm14:05:39

@rickmoynihan no extra meaning. That flag will continue to exist so that I can put directories generated with mktemp into the class path.

rickmoynihan14:05:09

ahh makes sense thanks

dominicm14:05:07

The "for building" is probably a bias in my writing for my particular use case.

rickmoynihan14:05:03

yeah — but that use case makes sense 🙂 the docs could possibly benefit from a clarification as to that purpose… but no biggie 🙂

rickmoynihan14:05:53

it is essentially the same as :extra-paths but more suited for scripting/api usage in wider build processes

👍 4
dominicm14:05:21

I'm terrible at writing documentation :)

rickmoynihan17:05:24

@dominicm: incidentally it seems that pack.alpha doesn’t seem to honor :extra-paths in other aliases you supply during the pack phase. I’m guessing this is a bug? Though I could have my wiring wrong.

dominicm17:05:50

Hmmm, that would be a bug, yeah.

dominicm17:05:00

I thought I tested that though

rickmoynihan17:05:18

ok I’ll open an issue for it — and also check it’s a real problem. Issue filed here: https://github.com/juxt/pack.alpha/issues/36

Daniel Hines18:05:06

Reposting noob cli question from #beginners: Is there a way to create a “default profile” for the clj cli? Such that whenever I run clj, certain deps are always merged in?

Daniel Hines18:05:51

like a ~/.deps.edn file or something?

rickmoynihan18:05:15

you can include custom (private) aliases in ~/.clojure/deps.edn but as far as I know you always have to opt in to aliases

rickmoynihan18:05:30

tools.deps prefers to be explicit

didibus18:05:35

Yes, put a deps.edn file here $HOME/.clojure

didibus18:05:02

Nah, you can just add normal deps

didibus18:05:07

And they'll always be included

didibus18:05:39

That's how Clojure itself gets loaded

👍 4
Daniel Hines18:05:12

Dumb question from a non-Java person: what is an “alias”? https://clojure.org/reference/deps_and_cli#_aliases doesn’t really explain that.

Daniel Hines18:05:48

Also, -S seems to be missing from that list of possible aliases.

didibus18:05:55

There are 3 deps.edn. The install one, the one in your home directory. And optionally, your project one. The :deps map gets merged from install to home to project. In case of conflicts, the later ones override the prior ones.

didibus18:05:35

Aliases are like dynamic modifications

didibus18:05:40

Normally, the classpath, that is, the path to all libraries available to your program is defined by the :deps map, and the :paths vector, and a few others.

didibus18:05:08

But, maybe on occasions, you want to start a program or a repl with more or less libraries included

didibus18:05:19

That's what aliases let you do

didibus18:05:36

So you can define sets of dependencies and name them with an alias.

didibus18:05:06

Now, from the command line, you can choose to include some of those additional sets by adding the alias for it

Daniel Hines18:05:37

That’s a very helpful explanation @didibus, thanks. So including aliases merges the options contained in those aliases?

Daniel Hines18:05:12

You said it’s possible exclude as well? How would that be accomplished, since it’s a merge?

didibus18:05:18

Pretty much. Now the way things are "merged" can vary depending in the type of alias and config.

didibus18:05:45

Well, you can't exactly exclude. So you'd be better off thinking of them more as inclusions

didibus18:05:05

But for example, you can specify :override-deps which will override versions

didibus18:05:50

Or :classpath-overrides which overrides the path to a lib

seancorfield18:05:27

@d4hines As an example of what you can do with ~/.clojure/deps.edn, here's mine https://github.com/seancorfield/dot-clojure/blob/master/deps.edn

seancorfield18:05:05

That has some usage notes as comments as well. Plus the README in that repo explains in more detail...

Daniel Hines19:05:10

This is super helpful, thanks!

didibus18:05:31

I'm not sure if you could classpath-override to a null dir

didibus18:05:42

Or a dir which doesn't have the dependency

didibus18:05:48

As a weird way to exclude

didibus18:05:59

But I wouldn't recommend it

didibus18:05:23

Better design it so aliases are additions or overrides, but not removals

didibus18:05:07

Also, I'm not sure what you mean by -S, that's just a prefix for other cli options. It's not related to aliases.