tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
imre 2020-11-23T14:27:44.029400Z

Alex, would it at all be in line with the direction of the clojure tools to allow -Spath '{:replace-deps {my/lib {,,,}}'. Or perhaps a switch like -Srepro that would turn off any local deps.edn sources?

imre 2020-11-23T14:29:28.030300Z

So that running tools from the command-line that don't need the project's classpath could become a little less verbose?

imre 2020-11-23T14:30:20.031Z

See https://github.com/tonsky/uberdeps/issues/33 for example

dominicm 2020-11-23T14:30:22.031300Z

@imre what were you doing when you wanted that feature?

imre 2020-11-23T14:31:03.032400Z

uberdeps, for example, as linked above

dominicm 2020-11-23T14:31:23.033100Z

Ah, I'd put an alias into -Sdeps for that, and activate it that way.

imre 2020-11-23T14:43:00.034100Z

Yeah, I understand that's the current solution šŸ™‚ Just asking whether it could be expected that an alias won't be needed sometime in the future

alexmiller 2020-11-23T14:51:18.035800Z

you can clj -Sdeps '{:aliases {:foo {:replace-deps {my/lib {,,,}} :main-opts ["-m" "my.main"]}}' -M:foo

alexmiller 2020-11-23T14:53:11.036800Z

I think there are definitely more things to do on tools and ad hoc tool usage like this is something that could be included

imre 2020-11-23T15:03:35.039200Z

Thanks both of you. -M:foo is what we've been using since we realized it doesn't work as we expected without an alias šŸ™‚ It is grand for the moment, although it won't work if there is an invalid deps.edn in the current folder. I look forward to future developments wrt tools and ad hoc usage improvements.

seancorfield 2020-11-23T19:40:13.040700Z

@borkdude (and others): I'm going to add a question on ask.clojure about having additional deps.edn files read in via clj/t.d.a. so I'd like some input from folks on what problem(s) this would solve for them -- in a thread please.

seancorfield 2020-11-23T19:41:07.040800Z

The first scenario that comes to my mind is a monorepo but Alex has asked for the problem statement to be couched in more general terms.

borkdude 2020-11-23T19:44:20.041Z

is this related to the CLJ_CONFIG + mvn-pom problem?

seancorfield 2020-11-23T19:44:38.041200Z

So I'd state the problem in these terms: 1. a development team works together on multiple projects that each have their deps.edn file, and 2. those developers have their own preferred tooling configured in their own ~/.clojure/deps.edn file, and 3. the team as a whole wants a level of consistency in terms of certain library or tooling versions across multiple projects, by providing some standardized aliases and some "pinned" versions (e.g., :override-deps). Currently, 1. and 2. are supported by the CLI/t.d.a. but there's nowhere to hang the multi-project standardization.

alexmiller 2020-11-23T19:45:03.041400Z

@borkdude no, not really. that problem is about how to convey cp modifications to -X programs

seancorfield 2020-11-23T19:45:18.041600Z

Currently, folks who want 3. are using CLJ_CONFIG to provide a team-standard deps.edn file but losing 1. in the process.

seancorfield 2020-11-23T19:46:57.041800Z

The cp/deps modification to -X programs is a separate (but also a real) issue that would benefit from some sort of standardized approach that could be used by tooling in general (not just mvn-pom). So let's keep that discussion separate.

seancorfield 2020-11-23T19:47:35.042Z

@borkdude Does my three-point problem statement match up with your CLJ_CONFIG use case, or is yours a separate scenario?

seancorfield 2020-11-23T19:50:29.044400Z

A separate issue that needs to go on ask.clojure to get votes and feedback is that it is fairly common for tooling to be want to read the deps.edn environment as if it were under a set of aliases, i.e., for a tool to want to see the world as if a specific set of aliases were provided, that are different to the aliases needed to run the tool. Discussion in a thread...

seancorfield 2020-11-23T19:51:57.044500Z

This touches on how -X.. mvn-pom works, as well as other tools on https://github.com/clojure/tools.deps.alpha/wiki/Tools such as depot: the environment needed to run the tool is not the same as the environment the tool wants for analysis.

seancorfield 2020-11-23T19:54:09.044700Z

depstar "works around" this problem by relying on its own runtime environment being the same as what goes into the JAR file but just excluding itself. This is only tenable because it is a very small tool that has zero external dependencies. You can override this and tell depstar to use a different classpath, but that approach doesn't work for tools that actually want to look at the versions of dependencies, such as mvn-pom, depot, etc.

alexmiller 2020-11-23T19:58:41.045Z

I do have this problem staked out in a table btw, just trying to decide on the right answer

borkdude 2020-11-23T19:58:48.045200Z

1) yes, 2) yes. 3) we use :default-deps for this with nil versions (as documented).

alexmiller 2020-11-23T20:00:27.045400Z

not sure yet whether it should be a feature, a set of conventions, a set of conventions + code to use those conventions, etc.

seancorfield 2020-11-23T20:01:46.045600Z

Ah, OK. So no need for an "ask" on this one?

alexmiller 2020-11-23T20:01:49.045800Z

the datomic ion dev tools is another example

alexmiller 2020-11-23T20:02:32.046Z

would be fine to have one, just by virtue of working on it for the datomic tools it's well on our radar already :)

borkdude 2020-11-23T20:04:05.046200Z

Right now it works well enough for me. Any tools I need for development I can also just put in our work repo's deps.edn. But it would be nice if I should not have to do that.

borkdude 2020-11-23T20:06:38.046600Z

In clj-kondo I have a concept called config-paths which is a list of dirs that possibly have a configuration for clj-kondo to be merged in. It's similar to CLJ_CONFIG, but CLJ_CONFIG only supports one and not a list of dirs.

borkdude 2020-11-23T20:07:01.046900Z

Basically a classpath for config.

borkdude 2020-11-23T20:07:37.047100Z

And your home dir's clj-kondo config is implicitly part of your config paths, unless you opt out of that

seancorfield 2020-11-23T20:14:47.047400Z

OK, I'll add a question for it then...

borkdude 2020-11-23T20:16:21.047600Z

> depstarĀ "works around" this problem by relying on its own runtime environment being the same as what goes into the JAR file but just excluding itself. I also have a couple of tools that just receive a --classpath arg. But it depends on the tool. For mvn pom that might not be so convenient, and getting a list of aliases to resolve versions with might be better.

alidlorenzo 2020-11-23T21:22:38.049600Z

I put a few constraints to get multiple unified deps configs to work well, i.e. subrepo aliases must be namespaced, since that makes them simple to merge and call from another directory

alexmiller 2020-11-23T21:34:52.050100Z

A prerelease version of clojure 1.10.1.739 is now available: ā€¢ When resolving pom models for local deps, use System properties so jdk profile activation works ā€¢ In tools.deps, updated specs to cover alias changes

2020-11-24T18:06:52.065200Z

@alexmiller I grabbed the pre-release on my Linux box and gave it a run. Fixes the problem with the local .jar + maven deps. Everything else is running smoothly. Much gratitude!

alexmiller 2020-11-24T18:08:53.065500Z

I just released it as an official release, same bits so no need to re-install

alexmiller 2020-11-23T21:35:24.050300Z

let me know if you see anything weird

vlaaad 2020-11-23T21:43:09.050500Z

replied there šŸ˜„

borkdude 2020-11-23T21:44:55.050800Z

@vlaaad Can you elaborate on how that would help with invoking mvn-pom?

seancorfield 2020-11-23T21:46:39.051Z

Is there an example of what that first bullet means that you can link me to (or easily describe)?

vlaaad 2020-11-23T21:47:47.051200Z

not sure that's what was asked.. did I read it wrong?

borkdude 2020-11-23T21:48:55.051400Z

The question is how can tools like mvn-pom be made aware of aliases that should be considered in adjunction to the local deps.edn

vlaaad 2020-11-23T21:54:25.051600Z

ah, well... tools like mvn-pom should accept basis as argument instead of a list of aliases. Converting aliases to basis should be the outer-most place in such tools.

dominicm 2020-11-23T21:56:08.051800Z

I'm guessing that it means that when specifying a jvm-specific dependency, that now works. @vlaaad :)

borkdude 2020-11-23T21:56:24.052Z

@vlaaad how do you pass a "basis" from the command line?

vlaaad 2020-11-23T21:59:12.052300Z

you don't, that's why you need to use t.d.a as a library

vlaaad 2020-11-23T22:00:04.052500Z

huh, me?

seancorfield 2020-11-23T22:00:26.052700Z

That's not a useful answer to this question.

seancorfield 2020-11-23T22:01:32.052900Z

I mean, yes, of course the tool has to use t.d.a but the point of this is to standardize an API so that all tooling can work from a set of aliases without having to reinvent the wheel and rely on knowing so much about how t.d.a works under the hood.

dominicm 2020-11-23T22:01:50.053100Z

@vlaaad didn't you ask for this in relation to jfx deps?

seancorfield 2020-11-23T22:02:18.053300Z

And this also builds on the other question I posted on ask.clojure which allows for additional deps.edn files to be included in the process.

vlaaad 2020-11-23T22:02:19.053500Z

well, cljfx uses activation profiles, but it always worked ĀÆ\(惄)/ĀÆ

seancorfield 2020-11-23T22:02:56.053700Z

We don't want every single tool out there to have to write that boilerplate code.

dominicm 2020-11-23T22:03:07.053900Z

Oh. So now I'm extra confused about what's new!

vlaaad 2020-11-23T22:03:10.054100Z

here is hoping for tools.build šŸ˜„

seancorfield 2020-11-23T22:03:32.054300Z

That still wouldn't address either of these two issues.

seancorfield 2020-11-23T22:04:56.054500Z

(and we also wouldn't want to tie arbitrary tooling to tools.build usage either)

seancorfield 2020-11-23T22:05:57.054700Z

Updated. Will let you know if I run into any issues (but I doubt either of those changes will affect our workflow).

vlaaad 2020-11-23T22:06:18.055Z

I have a feeling it is possible to build a variation of tools-deps that accepts multiple deps.edn files and configuration with aliases as args using tools.deps... as a library, that is then used with -X

seancorfield 2020-11-23T22:06:51.055200Z

These two issues both need to be solved inside t.d.a really.

seancorfield 2020-11-23T22:08:49.055400Z

Since -X mvn-pom needs a standardized way to do this, the solution will essentially be right there inside t.d.a -- once Alex et al have figured out the best way to solve it. I created the ask as a public placeholder for something that is already on Alex's plate, in a table of pros/cons for various solutions.

seancorfield 2020-11-23T22:11:02.055600Z

@alidcastano Interesting, but it looks/feels clunky as a workflow and is still just papering over the underlying problem -- which should really be solved inside t.d.a itself.

seancorfield 2020-11-23T22:11:28.055800Z

(monorepo is only a special case of the ask that I posted)

vlaaad 2020-11-23T22:15:41.056Z

I think my suggestion answers your question šŸ˜• There is a problem with mvn-pom , but any tool built on deps.edn can already build a basis given a set of aliases ā€” which is what you asked

alexmiller 2020-11-23T22:16:57.056700Z

See https://ask.clojure.org/index.php/9847/how-do-i-resolve-maven-dependencies-for-a-local-jar for an example failure case

alexmiller 2020-11-23T22:18:25.058300Z

Wouldnā€™t be an issue with maven deps, only with local

alidlorenzo 2020-11-23T22:20:40.058500Z

Iā€™d be interested in hearing what you feel is clunky about it. Unifying all subrepo deps and starting a clojure program with that unified config seems less clunky (imo) than overriding the cross-user project config and having to put all user dev related aliases into git history. i would have waited for this to be addressed in tools.deps but from slack searches, this issue has been present for over 2 years and only suggested solution in convos has been overriding the CLJ_CONFIG value, or using Lein. So I figured some experimentation in user space would be useful.

seancorfield 2020-11-23T22:23:02.058800Z

"having to put all user dev related aliases into git history" -- huh? No, no one is suggesting that.

borkdude 2020-11-23T22:23:36.059Z

I think you're right: it solves a problem users are experiencing now. Eventually this library might become obsolete, but in the meanwhile, I think some people may benefit from it.

seancorfield 2020-11-23T22:23:42.059200Z

Unless you mean "common tooling for the monorepo" -- in which case, yes, that sort of stuff should be under git.

seancorfield 2020-11-23T22:25:17.059400Z

@alidcastano Maybe I'm reading your project wrong, but it looks like you would need to run that preprocessing step to create the actual deps.edn file after any changes?

seancorfield 2020-11-23T22:27:31.060100Z

Your suggestion is actually the problem that I want solved. It isn't a solution šŸ™‚

alexmiller 2020-11-23T22:27:52.060700Z

Itā€™s not just aliases, there are other relevant params like -Srepro

seancorfield 2020-11-23T22:28:03.060900Z

We don't want every tool to have to write the same code over and over.

borkdude 2020-11-23T22:29:11.061100Z

@seancorfield I think what he's doing is spitting out a deps.edn at CLI invocation time and then your script invokes clojure using that deps.edn: https://github.com/rejoice-cljc/interdep/blob/c248b47d9e4a6f45982cac41f2ab3990d6f5e310/example/scripts/run.clj#L60

seancorfield 2020-11-23T22:29:15.061400Z

Yes, incorporating how -Srepro affects the merging of deps.edn would be important too. I don't use that flag right now because of course we have to rely on CLJ_CONFIG to "insert" that extra deps.edn file, which is why I didn't think to include it in the question šŸ˜

borkdude 2020-11-23T22:29:40.061700Z

so it writes on the fly, while you're invoking your commands

borkdude 2020-11-23T22:30:28.061900Z

so the used deps.edn is ephemeral

borkdude 2020-11-23T22:31:18.062100Z

which is a robust way of working around the current issues, since reading a single deps.edn is well supported

borkdude 2020-11-23T22:31:52.062300Z

I understand that this is not the way things should end, but it's a nice temporary hacky workaround :)

alidlorenzo 2020-11-23T22:34:35.062600Z

> ā€œhaving to put all user dev related aliases into git historyā€ -- huh? No, no one is suggesting that. @seancorfield I imagined that by overriding CLJ_CONFIG and not having a user cross project config, that devs would need to put their own custom configurations in git history. but perhaps you work around that, too, not sure.

borkdude 2020-11-23T22:38:06.062800Z

@alidcastano I see your example script runs clojure in a .main subdir. Doesn't this cause issues with relative file paths in an app?

alidlorenzo 2020-11-23T22:38:59.063Z

right now this is a simple library that provides utilities for processing nested deps.edn configurations, along with constraints that standardize the experience, document it, and make it more robust. itā€™s up to the user how they want to start their program, since thereā€™s many different ways someone may want to do that. the way the example in the repo does it, is it calls the two helper utilities (`multi-repo/process-deps` and multi-alias/with-profiles) and those return a map with the values of the main deps config and the activated aliases. then it writes that deps config to a subdir and uses babaskha to start the clojure process from there https://github.com/rejoice-cljc/interdep/blob/c248b47d9e4a6f45982cac41f2ab3990d6f5e310/example/scripts/run.clj#L57-L72

borkdude 2020-11-23T22:41:14.063400Z

I think it's better to start clojure from the directory you are in. So maybe it should support reading files that are not named deps.edn so it can spit out to deps.edn locally (because clojure doesn't currently have the option to point at another local deps2.edn file)

borkdude 2020-11-23T22:41:57.063600Z

Note that https://github.com/borkdude/deps.clj (also works with babashka btw) supports -Sdeps-file. I'll end the hackathon discussion here. Going to bed now :).

alidlorenzo 2020-11-23T22:48:38.064Z

> I see your example script runsĀ `clojure`Ā in aĀ `.main`Ā subdir. Doesnā€™t this cause issues with relative file paths in an app? @borkdude multi-repo/process-deps accepts :out-dir option that makes any paths relative to the desired directory but reading deps file from root directory is a good idea. Iā€™ll see if that can be done with tools.deps; thanks for feedback, rest well!

seancorfield 2020-11-23T23:29:11.064200Z

@alidcastano > I imagined that by overriding CLJ_CONFIG and not having a user cross project config, that devs would need to put their own custom configurations in git history. but perhaps you work around that, too, not sure. Yeah, it's definitely a compromise. We have an agreed subset of tooling that's in the "master" deps.edn file, that satisfies everyone's needs for working on the monorepo. Luckily, we're all fans of fairly minimal tooling so we work with either plain REPLs or Socket REPLs. Mostly, the shared dev aliases are around testing and packaging (which of course we want standardized across the team, across all subprojects) and we have a :dev alias that points at a subproject in the monorepo that knows how to start various REPLs/tooling, based on whatever happens to be on your classpath (i.e., based on the set of aliases you used).

seancorfield 2020-11-23T23:37:15.064400Z

I think if we decided to switch to some sort of rewriting tool at startup, we'd want to keep it pretty simple: just slurping the "master" deps.edn file, reading it as EDN, sucking out a couple of the aliases, and just assoc'ing those into the local project deps.edn and writing it back out. FWIW, we already have a tool that merges all the subproject deps.edn files and writes to an everything pseudo-subproject that we can use as a convenient place to start a REPL if we want the entire codebase available (which is normally how I work). We manually build it, as needed, and we keep it under git. It still assumes the "master" deps.edn file is in play with its :defaults alias to specify :override-deps for everything.