tools-deps

p-himik 2024-09-08T09:08:51.073279Z

Given https://clojurians.slack.com/archives/C03S1KBA2/p1725754474109679 there doesn't seem to be a way to specify a single Clojure version for a monorepo that has different directories with their own deps.edn. Or is there still an approach that doesn't involve programmatic deps.edn manipulation and version duplication?

seancorfield 2024-09-17T17:37:50.599569Z

I guess it's somewhat ironic that Ask got closed as a duplicate of an Ask I posted four years ago...

p-himik 2024-09-17T17:52:46.859879Z

Huh, apparently there are no notifications from the website when an Ask is closed. @alexmiller I'd say that the two Asks are different, especially when the linked Jira ticket is considered. The Jira ticket talks about multiple people/projects/tools/aliases - all of that is irrelevant to the Ask that I've posted. Neither the older Ask nor the Jira ticket talk about the version of Clojure - which is my only concern here. Within the context of what I'm doing, all the bullet points in the Jira ticket work just fine where I have a single common directory with all the common dependencies. But it still doesn't let me specify the version of Clojure, and only Clojure.

Alex Miller (Clojure team) 2024-09-17T17:55:25.283969Z

Is it not multiple projects sharing config?

p-himik 2024-09-17T17:59:04.484759Z

Depends on what you mean by "project". In my case, it's a single directory with a structure like this:

root
- src
  - ...
- lib
  - common
    - deps.edn
  - lib1
    - deps.edn
  - lib2
    - deps.edn
- deps.edn
I specify all the common deps in lib/comon/deps.edn, everything works perfectly. With the only exception of the version of org.clojure/clojure.

seancorfield 2024-09-17T18:01:39.449939Z

FWIW, our adoption of Polylith side-stepped the problem that led me to Ask that, so I never followed up, but originally I was looking for something similar to what Eugene is Asking for... and I assumed that whatever solution eventually came along would include fixing the org.clojure/clojure version across projects (currently, the only option is an alias and :override-deps?).

Alex Miller (Clojure team) 2024-09-17T18:13:06.081809Z

there are potentially several ways to give new functionality here

seancorfield 2024-09-08T16:47:50.479529Z

This is part of why Polylith uses a top-level deps.edn with a :dev alias as the way to run a REPL for the whole monorepo, and then a primary deps.edn for each "project" that gets built. You have to specify Clojure's version in :dev (for the REPL) and for each project, but not for any components within the repo.

p-himik 2024-09-08T16:49:29.440229Z

That works for run-time, but doesn't play nice with at least Cursive because sub-projects are resolved separately (which makes sense, since they have their own deps.edn each).

seancorfield 2024-09-08T16:50:05.143829Z

There's a recently-added setting in Cursive to support Polylith, I think?

p-himik 2024-09-08T16:50:38.936549Z

But I don't use Polylith. :) It's a drastic overkill in my case.

seancorfield 2024-09-08T16:50:48.435559Z

(it was a longstanding problem with Cursive that it didn't play nice with Polylith, but Colin did a lot of work this past year on getting that to work I think?)

seancorfield 2024-09-08T16:51:30.126029Z

I'm suggesting that whatever he changed in Cursive would help here...?

p-himik 2024-09-08T16:54:06.172449Z

@cfleming What do you think? Among any potentially relevant options, I only see "Resolve over whole project" but I have no idea what it means and entails. I also think that I can specify Clojure version for the whole project implicitly, via choosing the right deps.clj version. But that's, well, implicit. And it doesn't yet have a version that brings in 1.12.0.

seancorfield 2024-09-08T16:55:02.359269Z

I think "Resolve over whole project" is how it supports the top-level deps.edn as applying across everything -- it was part of the Polylith support, I'm pretty sure.

cfleming 2024-09-09T01:19:33.401829Z

That flag was added for Polylith, but I'm not sure it helps in this case - it depends on the structure of your app. What that flag does is: when Cursive is resolving a symbol, instead of just checking the current module (a project, in deps terms, i.e. something with a deps.edn), it will check the whole project. This is because Polylith allows you to have code in one module which needs to refer to code in another module, without an explicit dependency between them.

cfleming 2024-09-09T01:20:26.975279Z

So, if you have one deps project, which pulls in code from other secondary deps projects without an explicit dependency, that flag will help. But it doesn't do anything at the deps level.

cfleming 2024-09-09T01:22:34.402869Z

As far as I know, the answer to p-himik's question is "no". I don't think there's any way to do that, since aliases in deps are not transitive and there's no concept of anything like build variables.

cfleming 2024-09-09T01:23:49.397899Z

Personally, for Cursive I have a few scripts which update my deps files programmatically using rewrite-clj, which feels janky but in practice isn't as terrible as I thought it would be.

seancorfield 2024-09-09T04:22:12.723049Z

Thanks for the clarification on that @cfleming I guess my approach, in that case, would be to do as much as possible via build.clj at the top-level, and have it perform the project-specific operations programmatically and inject the top-level version of Clojure into each sub-project's basis when it is doing stuff? I'd need more details about exactly what operations you wanted to run on those sub-projects where you'd want a fixed, overriding version of Clojure applied...