Fork me on GitHub
#tools-deps
<
2023-03-09
>
sashton21:03:37

What would be the most straightforward way to run with a custom version of tools.deps? I’ve tried using replace-deps with my local root like so: :aliases {:deps {:replace-deps {org.clojure/tools.deps {:local/root "_____/tools.deps"}}} . I’ve seen other mentions of replacing deps this way elsewhere in this channel (https://clojurians.slack.com/archives/C6QH853H8/p1607026303165100). However, although I’ve added printlns and file I/O in a number of places in my copy of tools.deps to verify my custom version is working, I don’t observe any of my expected output. I was hoping that running with one of the following would execute using my custom version:

clj -Stree
clj -A:deps -Stree
Is what I am attempting possible?

borkdude22:03:03

@U08TWB99B Your question can mean several things. Do you want the clojure CLI itself to use your fork, or do you want your build.clj to use your tools deps fork

sashton22:03:48

I guess it would be clojure CLI

borkdude22:03:34

the clojure CLI uses a pre-built uberjar containing tools.deps. It doesn't use a version that is described in your deps.edn. But you should see that custom version in clj -Stree

borkdude22:03:09

e.g. if you would do:

clj
(require '[clojure.tools.deps])
it should end up using your fork

seancorfield22:03:49

To avoid confusion, I would recommend using a different alias for testing, since :deps is a built-in alias in the "root" deps.edn (which is inside tools.deps).

🤞 2
sashton22:03:53

@U04V15CAJ But would that happen before dependencies are resolved? In particular, what I’m trying to do is add some sort of offline mode for git dependency resolution. My work VPN is causing me serious headaches accessing off-VPN git libs, and they change so infrequently that I would be okay running with cached versions for periods of time. So, if tools.deps is bundled in the uberjar, I’m thinking I’ll need to build that. I have tried poking around to figure out where that is built, but I haven’t figured that out yet, either.

borkdude22:03:13

I mean, yes, you need to build your own uberjar

sashton22:03:39

Any idea where that happens?

borkdude22:03:45

if it helps, here is a re-implementation of the bash portion of the CLI: https://github.com/borkdude/deps.clj but it still downloads the uberjar from http://clojure.org

Alex Miller (Clojure team)22:03:14

with clj -T:build release

sashton22:03:43

Thanks! I’ll start there

Alex Miller (Clojure team)22:03:21

the uber jar ends up in target/clojure-tools-<version>.jar

Alex Miller (Clojure team)22:03:42

but this is not a sustainable path to an environment, really only suitable to testing something

Alex Miller (Clojure team)22:03:31

depending on your scenario, you may be able to solve this with the existing git support

Alex Miller (Clojure team)22:03:48

which supports local file path git repos

Alex Miller (Clojure team)22:03:30

but it depends how much git stuff you are depending on and whether those have transitive git deps too

sashton22:03:19

Yeah, I think that would be complicated with transitive dependencies.

Alex Miller (Clojure team)22:03:35

well you can rewrite git urls in git itself

Alex Miller (Clojure team)22:03:56

you should be able to set git config that rewrites your external git urls to local git urls. because tools.deps (really tools.gitlibs) uses git, it will also use that

sashton22:03:59

That would be interesting. I’ll take a look at that option first.

Alex Miller (Clojure team)22:03:24

just as a meta observation - start with the actual problem here :)

Alex Miller (Clojure team)22:03:09

"My work VPN is causing me serious headaches accessing off-VPN git libs, and they change so infrequently that I would be okay running with cached versions for periods of time." is a good problem statement :)

Alex Miller (Clojure team)22:03:37

and just fyi, there are also tools that do this sort of thing at an enterprise level (just like they do with maven repos), and I would very much like to support those well eventually, not just for performance but for enterprise control/threat containment

sashton22:03:48

Nice! insteadOf handles my case. I like that much better. Thanks!