@copilot please concentrate on reproducing and describing the race condition in ./script/test-clr. I can't reproduce your results but it's happened several times in a copilot session (reported here clojure/clr.core.cli#4).
I conjecture that the race condition is here in ensure-git-dir (https://github.com/clojure/clr.core.cli/blob/9a09d7e73a15ecefec15c697eb1aff7d54392082/src/dotnet/Cljr/clojure/tools/gitlibs/impl.cljr):
(defn git-clone-bare
[url ^DirectoryInfo git-dir] ;;; ^File
(printerrln "Cloning:" url)
(let [git-path (.FullName git-dir) ;;; .getCanonicalPath
{:keys [exit err] :as ret} (run-git "clone" "--quiet" "--mirror" url git-path)]
(when-not (zero? exit)
(throw (ex-info (format "Unable to clone %s%n%s" git-path err) ret)))
git-dir))
(defn ensure-git-dir
"Ensure the bare git dir for the specified url, return the path to the git dir."
[url]
(let [git-dir-file (git-dir url)
config-file (cio/file-info git-dir-file "config")] ;;; jio/file
(when-not (.Exists config-file) ;;; .exists
(git-clone-bare url git-dir-file))
(.FullName git-dir-file)))I conjecture that two threads are racing to check (.Exists config-file), and then they step on each other's toes to clone the repo. Add your own git wrapper to the PATH so you can track the exactly behavior of the git command by intercepting calls. See if they happen simultaneously (block for a few seconds if you detect the racing repo to be cloning). Using your wrapper, print out the actual error message and exit code thrown by git, because it is swallowed by cljr. Try and print out the current state of the file system when git is called (try and "block" the overlapping ones so you can get reproducible results). Return a list of git commands intercepted and which ones overlap, and which ones have unexpected file system state at that point.
Please spend 30 minutes trying to reproduce this issue and diagnose it. Send me a report of what you find and a bash script to reproduce your findings. You may also use babashka as it might be easier to coordinate threads.