Fork me on GitHub
#tools-deps
<
2022-01-17
>
emccue03:01:28

If i have a deps.edn that looks like this

{:deps {a/b {...}}
 :aliases {:build {:deps {c/d {...}}}}}
Is there a way to create a basis that just has the deps from the build alias, and not a/b (to my understanding this is what clj -T … does)

Alex Miller (Clojure team)04:01:56

yes, but it will not be identical to -T without a small bit of modification. not sure which api you're using to create the basis (`tools.deps.alpha/create-basis`, tools.cli.api/basis, or tools.build.api/create-basis - they are all slightly different), but they can all take an :aliases [:build] argument

Alex Miller (Clojure team)04:01:09

the one difference from -T is that -T adds "." to the :paths . you can either make this explicit by putting it in the :build alias :paths, or you can also pass a :extra {:paths ["."]} to any of those api calls above too

emccue06:01:40

tools.deps.alpha/create-basis

emccue06:01:33

and it turns out the reason i was so confused is that i was passing the aliases as strings, which resolved to nothing, and then i saw the root classpath

zackteo07:01:29

Is there a way I can add a truststore as a JVM parameter? In deps.edn? Am getting sun.security.validator.ValidatorException which I understand I need to doing something like -Djavac.net.ssl.trustStore=.... but I'm not sure how to go about it for deps edn cause previously when using lein I could set my env var of JVM_OPTS

dharrigan07:01:39

Can you pass it though, i.e., clojure -.ssl... -M:alias1:alias2....?

dharrigan08:01:07

For example, I have an shell alias that starts up clojure in debug...`clojure -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -J-Dclojure.core.async.go-checking=true -M:foo:bar`

zackteo08:01:42

Oooo! That works I was putting it in as a vector so that was the problem 😅

zackteo08:01:21

But now I need to make sure it integrates the editors my team uses :x the jvm-opts part that is

zackteo08:01:52

@dharrigan do you know of anyway to get configure deps.edn apply the jvm-opts based on an env variable etc

dharrigan08:01:28

Like doing "${SOME_ENV}" in the deps.edn? If so, no, I don't believe the deps.edn is run through any shell expansion.

zackteo08:01:21

Hmmm more like how lein would use JVM-OPTS and apply that to whatever java command is ran when running lein

dharrigan08:01:59

No, I don't believe there is any functionality for that.

zackteo08:01:30

I'm reading the reference docs and might this be what I want? JVM arguments may either be passed on the command line (with -J) or by using data stored in an alias under :jvm-opts and passed with -X or -A or -M

zackteo08:01:29

I dont quite understand what does the latter mean exactly

dharrigan08:01:23

The first example is the one I gave above, i.e., to pass in the JVM parameters as the clj process is created, the second option, here is an example

zackteo08:01:58

The part I don't quite understand is that

:repl/nrepl
  {:extra-deps {nrepl/nrepl                {:mvn/version "0.9.0"}}
   :main-opts  ["-m" "nrepl.cmdline"]}
This works when I do clojure -J-Djavax.... -M:repl/nrepl

zackteo08:01:53

But when I modify it

:repl/nrepl
  {:extra-deps {nrepl/nrepl                {:mvn/version "0.9.0"}}
   :jvm-opts ...
   :main-opts  ["-m" "nrepl.cmdline"]}
clojure -M repl/nrepl doesn't work. It seems like the jvm-opts isn't being applied

dharrigan09:01:28

I think it's being applied for me, ...

dharrigan09:01:43

:local-dev {:extra-deps {local-dev/local-dev {:local/root "/home/david/.clojure/libs/local.dev" :deps/manifest :deps}}
              :jvm-opts ["-Djavax.net.ssl.trustStore=/home/david/foo"]
              :main-opts ["-m" "local.dev.main"]}

dharrigan09:01:56

So, I launched a Main, passing in jvm-opts, then used visualvm to confirm that the JVM had started with the -D set.

zackteo12:01:27

Thanks for your help! Let me look into it again :)

emccue19:01:03

terminology question - why alias instead of profile

vlaaad19:01:13

Because it aliases a piece of data with a name

vlaaad19:01:35

I remember hearing a sentiment from @U064X3EF3 that aliases might contain completely arbitrary data that can be passed to clojure programs

vlaaad19:01:30

It seems there isn't much support for that now, but maybe it's coming? :thinking_face:

Alex Miller (Clojure team)20:01:48

This is the correct sense of it, tools.deps happens to be the most prominent user of this data

Alex Miller (Clojure team)20:01:55

Support for this is partially there, more to come

slimslenderslacks02:01:48

While building a -T:tool style tool, I also wondered about whether users would expect a tool's config map to be passed as an alias - I ended up just reading the config from a seperate .edn file. If I needed different configurations for different "profiles", there didn't seem to be a way to use the cli to select one of them ( clojure -T:tool -A:config2 or something like that).

Alex Miller (Clojure team)03:01:42

It is kind of possible now by reading the injected basis, but I think this is an area where more could be done by referencing aliases