tools-build 2021-09-18

Alex Miller (Clojure team) 2021-09-18T12:30:58.279Z

We have a ticket for this, I haven’t had time to work on it yet but I think there’s things we can do in tools.gitlibs

Thank you!

@seancorfield Hi. I'm trying to use build-clj and didn't catch where is this lib is saved after cloning? I need to use it in a closed environment without Internet and I need to know where should I put it in a CI server. Steps I did: 1. Put in deps.edn

:build    {:deps       {io.github.seancorfield/build-clj
                        {:git/tag "v0.3.1" :git/sha "996ddfa"}}
           :ns-default build}
2. I run clojure -T:build and I see in output Checking out: at 996ddfacbdb4454a6e6904690802f26dc5637cf2 Can't find where is this lib saved?

$HOME/.gitlibs

You're most welcome 🙂

@mike1452 In CI we have this (in addition to a standard Maven cache):

caches:
    # for CLI/deps.edn (uses standard maven cache):
    clojure: ~/.clojure
    gitlibs: ~/.gitlibs
The .clojure folder doesn't buy you much but the .gitlibs folder is very helpful for us as we use a lot of git deps for tooling!

@seancorfield Thank you! I'll take it.

FYI, I've expanded the build-clj readme to clarify that it is "just" a wrapper around tools.build that codifies and expands on the examples from the official guide on http://clojure.org -- I've also added more information about test running, including showing how you can get build-clj to use Kaocha, just by changing the :test alias in your deps.edn file.

Hello, I have a 3 project monorepo at https://github.com/bob-cd/bob (the apiserver, entities and runner dirs) and moved it to tools.build from depstar. I have an orchestration to test and build uberjars in parallel. In the CI, I run all the tests in each sequentially and the uberjars in parallel. More often than once i get hit by this when i start the calls to clojure -T:build uber in the three dirs in parallel:

Cloning: 
Checking out:  at 3247680a07fcf6b0ff7e4cbac8b4ac8d73c12ace
Checking out:  at 3247680a07fcf6b0ff7e4cbac8b4ac8d73c12ace
Error building classpath. Unable to checkout 3247680a07fcf6b0ff7e4cbac8b4ac8d73c12ace
fatal: '/root/.gitlibs/libs/io.github.clojure/tools.build/3247680a07fcf6b0ff7e4cbac8b4ac8d73c12ace' already exists

Error while executing task: compile
Error in task: -compile
Error in task: runner
Error while executing task: runner
Error building classpath. Unable to clone /root/.gitlibs/_repos/github.com/clojure/tools.build
BUG: refs/files-backend.c:2956: initial ref transaction called with existing refs
if i remove ~/.gitlibs before the calls seems to work. didnt have this issue with depstar. not sure where the issue could be, any help is appreciated! 😄

this can be reproduced by running clojure -Stree in the dirs and then clojure -T:build uber in parallel in them

@rahul080327 That sounds like a straightforward race condition in the CLI itself since you're forcing it to attempt to download the same git dep in parallel. I would recommend running one or more "prepare" commands to get the deps in place first and then run the tasks in parallel:

clojure -P -A:build
clojure -P
- par:
  clojure -T:build uber
  clojure -T:build uber

After all you have to download the deps at some point and you only need to do it once.

@seancorfield yes i had the same impression that parallel git clones are causing it, but was wondering that shouldn’t git be resilient to itself somehow maybe? Anyways i will implement what youre recommending, thanks 🙏