clojure / clojure/clr.core.cli

Intermittent error: `Error building classpath. Unable to clone '<dep>' already exists and is not an empty directory`

Open
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
8
Forks
5
PR merge metrics
No merged PRs in 30d

Description

I noticed a plausible intermittent error in a copilot session. A gitlib is cloned twice in the same dependency tree, and an error is thrown. I have not reproduced it and copilot has successfully run this project many times before, but in this particular session (appended at the bottom) the error occurred.

I have the following deps-clr.edn:

{:paths ["src" "test-resources"]
 :deps {org.typedclojure/typed.clj.runtime {:local/root "../clj.runtime"
                                            :deps/manifest :deps}
        org.typedclojure/typed.clj.analyzer {:local/root "../clj.analyzer"
                                             :deps/manifest :deps}
        org.clojure/math.combinatorics {:git/url "https://github.com/frenchy64/math.combinatorics"
                                        :git/sha "e4a4f82e74ce750e8a45dee2f8e306b53971fe4f"}
        org.clojure/core.cache {:git/url "https://github.com/clojure/clr.core.cache.git"
                                :git/sha "ee7fa0f618ebd1ea00130a1b648778bdefcf059b"}
        org.clojure/tools.namespace {:git/url "https://github.com/clojure/clr.tools.namespace.git"
                                     :git/sha "46d81cba650eaf7bc9d9aa79700d0d7e496e987f"}
        org.clojure/tools.reader {:git/url "https://github.com/clojure/clr.tools.reader.git"
                                  :git/sha "46ce896e51f1707b45afd128fe634f0735ad477b"}}
 :aliases
 {:test
  {:extra-paths ["test"]
   :extra-deps {io.github.dmiller/test-runner {:git/tag "v0.5.3clr" :git/sha "ae91dd2727bbf70eb3a6d869a19953de3819dfbc"}}
   :main-opts ["-m" "cognitect.test-runner"]}}}
;; ../clj.runtime/deps-clr.edn
{:paths ["src" "resources"]
 :aliases
 {:test
  {:extra-paths ["test"]
   :extra-deps {io.github.dmiller/test-runner {:git/tag "v0.5.3clr" :git/sha "ae91dd2727bbf70eb3a6d869a19953de3819dfbc"}}
   :main-opts ["-m" "cognitect.test-runner"]}}}
;; ../clj.analyzer/deps-clr.edn
{:paths ["src"]
 :deps {org.typedclojure/typed.cljc.analyzer {:local/root "../cljc.analyzer"
                                              :deps/manifest :deps}}
 :aliases
 {:test
  {:extra-paths ["test"]
   :extra-deps {io.github.dmiller/test-runner {:git/tag "v0.5.3clr" :git/sha "ae91dd2727bbf70eb3a6d869a19953de3819dfbc"}}
   :main-opts ["-m" "cognitect.test-runner"]}}}
;; ../cljc.analyzer/deps-clr.edn
{:paths ["src"]
 :aliases
 {:test
  {:extra-paths ["test"]
   :extra-deps {io.github.dmiller/test-runner {:git/tag "v0.5.3clr" :git/sha "ae91dd2727bbf70eb3a6d869a19953de3819dfbc"}}
   :main-opts ["-m" "cognitect.test-runner"]}}}

Copilot attempted to debug the problem, this was the most interesting log where the clone is deleted before running cljr:

$ rm -rf /home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader && cd /home/runner/work/typedclojure/typedclojure/typed/clj.checker && bash ./script/test-clr 2>&1 | tail -150
Running typed.clj.checker tests under ClojureCLR...
Cloning: https://github.com/clojure/clr.tools.reader.git
Cloning: https://github.com/clojure/clr.tools.reader.git
Error building classpath. Unable to clone /home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader
fatal: destination path '/home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader' already exists and is not an empty directory.
<exited with exit code 0>

./script/test-clr simply calls cljr -M:test.

Here's the versions that were installed:

      - name: Setup .NET
        uses: actions/setup-dotnet@v5
        with:
          dotnet-version: '8.0.x'
      
      - name: Install ClojureCLR and cljr
        run: |
          # Install ClojureCLR as a dotnet tool
          dotnet tool install --global Clojure.Main --version 1.12.3-alpha3
          # Install cljr CLI tool
          dotnet tool install --global Clojure.Cljr --version 0.1.0-alpha8
          echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
Full Copilot session

From a copilot session, noticed the duplicated Cloning: https://github.com/clojure/clr.tools.reader.git forms:

Copilot: Now let me run the CLR tests to find and fix remaining errors:

$ cd /home/runner/work/typedclojure/typedclojure/typed/clj.checker && bash ./script/test-clr 2>&1 | tail -100
Running typed.clj.checker tests under ClojureCLR...
Cloning: https://github.com/dmiller/test-runner.git
Cloning: https://github.com/frenchy64/math.combinatorics
Checking out: https://github.com/frenchy64/math.combinatorics at e4a4f82e74ce750e8a45dee2f8e306b53971fe4f
Cloning: https://github.com/clojure/clr.core.cache.git
Checking out: https://github.com/clojure/clr.core.cache.git at ee7fa0f618ebd1ea00130a1b648778bdefcf059b
Cloning: https://github.com/clojure/clr.tools.namespace.git
Cloning: https://github.com/clojure/clr.data.priority-map.git
Checking out: https://github.com/clojure/clr.tools.namespace.git at 46d81cba650eaf7bc9d9aa79700d0d7e496e987f
Cloning: https://github.com/clojure/clr.tools.reader.git
Cloning: https://github.com/clojure/clr.tools.reader.git
Checking out: https://github.com/clojure/clr.tools.reader.git at 46ce896e51f1707b45afd128fe634f0735ad477b
Checking out: https://github.com/dmiller/test-runner.git at ae91dd2727bbf70eb3a6d869a19953de3819dfbc
Checking out: https://github.com/clojure/clr.data.priority-map.git at 1c2275130eb92941e4c26de1110f23ca0d16b706
Error building classpath. Unable to clone /home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader
fatal: destination path '/home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader' already exists and is not an empty directory.
<exited with exit code 0>

Copilot: There's a git cache issue. Let me clean it and try again:

$ rm -rf /home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader && cd /home/runner/work/typedclojure/typedclojure/typed/clj.checker && bash ./script/test-clr 2>&1 | tail -150
Running typed.clj.checker tests under ClojureCLR...
Cloning: https://github.com/clojure/clr.tools.reader.git
Cloning: https://github.com/clojure/clr.tools.reader.git
Error building classpath. Unable to clone /home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader
fatal: destination path '/home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader' already exists and is not an empty directory.
<exited with exit code 0>

Copilot: Clear .gitlibs completely and try again.

$ rm -rf /home/runner/.gitlibs && cd /home/runner/work/typedclojure/typedclojure/typed/clj.checker && timeout 280 bash ./script/test-clr 2>&1 | tail -200
Running typed.clj.checker tests under ClojureCLR...
Cloning: https://github.com/dmiller/test-runner.git
Cloning: https://github.com/frenchy64/math.combinatorics
Checking out: https://github.com/frenchy64/math.combinatorics at e4a4f82e74ce750e8a45dee2f8e306b53971fe4f
Cloning: https://github.com/clojure/clr.core.cache.git
Checking out: https://github.com/clojure/clr.core.cache.git at ee7fa0f618ebd1ea00130a1b648778bdefcf059b
Cloning: https://github.com/clojure/clr.tools.namespace.git
Cloning: https://github.com/clojure/clr.data.priority-map.git
Checking out: https://github.com/clojure/clr.tools.namespace.git at 46d81cba650eaf7bc9d9aa79700d0d7e496e987f
Cloning: https://github.com/clojure/clr.tools.reader.git
Cloning: https://github.com/clojure/clr.tools.reader.git
Checking out: https://github.com/clojure/clr.tools.reader.git at 46ce896e51f1707b45afd128fe634f0735ad477b
Checking out: https://github.com/dmiller/test-runner.git at ae91dd2727bbf70eb3a6d869a19953de3819dfbc
Checking out: https://github.com/clojure/clr.data.priority-map.git at 1c2275130eb92941e4c26de1110f23ca0d16b706
Error building classpath. Unable to clone /home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader
fatal: destination path '/home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader' already exists and is not an empty directory.
<exited with exit code 0>

Copilot: The git cache issue persists. Let me try a different approach - check if there's a lock file or corrupted repo:

$ ls -la /home/runner/.gitlibs/_repos/https/github.com/clojure/ 2>/dev/null | head -20
total 24
drwxrwxr-x 6 runner runner 4096 Oct 24 13:42 .
drwxrwxr-x 5 runner runner 4096 Oct 24 13:42 ..
drwxrwxr-x 7 runner runner 4096 Oct 24 13:42 clr.core.cache
drwxrwxr-x 7 runner runner 4096 Oct 24 13:42 clr.data.priority-map
drwxrwxr-x 7 runner runner 4096 Oct 24 13:42 clr.tools.namespace
drwxrwxr-x 7 runner runner 4096 Oct 24 13:42 clr.tools.reader
<exited with exit code 0>

Copilot: The directory exists. Let me check if there's a duplicate git clone attempt happening:

The directory exists. Let me check if there's a duplicate git clone attempt happening:

$ cd /home/runner/work/typedclojure/typedclojure/typed/clj.checker && cat deps-clr.edn | head -30
{:paths ["src" "test-resources"]
 :deps {org.typedclojure/typed.clj.runtime {:local/root "../clj.runtime"
                                            :deps/manifest :deps}
        org.typedclojure/typed.clj.analyzer {:local/root "../clj.analyzer"
                                             :deps/manifest :deps}
        org.clojure/math.combinatorics {:git/url "https://github.com/frenchy64/math.combinatorics"
                                        :git/sha "e4a4f82e74ce750e8a45dee2f8e306b53971fe4f"}
        org.clojure/core.cache {:git/url "https://github.com/clojure/clr.core.cache.git"
                                :git/sha "ee7fa0f618ebd1ea00130a1b648778bdefcf059b"}
        org.clojure/tools.namespace {:git/url "https://github.com/clojure/clr.tools.namespace.git"
                                     :git/sha "46d81cba650eaf7bc9d9aa79700d0d7e496e987f"}
        org.clojure/tools.reader {:git/url "https://github.com/clojure/clr.tools.reader.git"
                                  :git/sha "46ce896e51f1707b45afd128fe634f0735ad477b"}}
 :aliases
 {:test
  {:extra-paths ["test"]
   :extra-deps {io.github.dmiller/test-runner {:git/tag "v0.5.3clr" :git/sha "ae91dd2727bbf70eb3a6d869a19953de3819dfbc"}}
   :main-opts ["-m" "cognitect.test-runner"]}}}
<exited with exit code 0>

Copilot: I see - there's a single entry for tools.reader, but the error shows it's being cloned twice. This might be a timing issue. Let me try running it with a longer wait and see the actual test output:

$ cd /home/runner/.gitlibs/_repos/https/github.com/clojure && ls -d clr.tools.reader* 2>/dev/null && rm -rf clr.tools.reader* && cd /home/runner/work/typedclojure/typedclojure/typed/clj.checker && bash ./script/test-clr 2>&1
clr.tools.reader
Running typed.clj.checker tests under ClojureCLR...
Cloning: https://github.com/clojure/clr.tools.reader.git
Cloning: https://github.com/clojure/clr.tools.reader.git
Error building classpath. Unable to clone /home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader
fatal: destination path '/home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader' already exists and is not an empty directory.
<exited with exit code 1>

Copilot: The issue might be a ClojureCLR tools.deps bug. Let me try pre-cloning the repo manually and then running the test:

$ cd /home/runner && rm -rf .gitlibs && mkdir -p .gitlibs/_repos/https/github.com/clojure && cd .gitlibs/_repos/https/github.com/clojure && git clone https://github.com/clojure/clr.tools.reader.git 2>&1 | tail -5 && cd /home/runner/work/typedclojure/typedclojure/typed/clj.checker && timeout 280 bash ./script/test-clr 2>&1 | tail -100
Cloning into 'clr.tools.reader'...
Running typed.clj.checker tests under ClojureCLR...
Cloning: https://github.com/dmiller/test-runner.git
Cloning: https://github.com/frenchy64/math.combinatorics
Checking out: https://github.com/frenchy64/math.combinatorics at e4a4f82e74ce750e8a45dee2f8e306b53971fe4f
Cloning: https://github.com/clojure/clr.core.cache.git
Checking out: https://github.com/clojure/clr.core.cache.git at ee7fa0f618ebd1ea00130a1b648778bdefcf059b
Cloning: https://github.com/clojure/clr.tools.namespace.git
Cloning: https://github.com/clojure/clr.data.priority-map.git
Checking out: https://github.com/clojure/clr.tools.namespace.git at 46d81cba650eaf7bc9d9aa79700d0d7e496e987f
Cloning: https://github.com/clojure/clr.tools.reader.git
Cloning: https://github.com/clojure/clr.tools.reader.git
Error building classpath. Unable to clone /home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader
fatal: destination path '/home/runner/.gitlibs/_repos/https/github.com/clojure/clr.tools.reader' already exists and is not an empty directory.
<exited with exit code 0>

This is definitely a ClojureCLR bug - it's trying to clone the same repo twice. Let me work around it by using a lock file approach or check the test runner script:

#!/bin/bash
# Run tests for typed.clj.checker under ClojureCLR
#
# Prerequisites:
# - cljr (ClojureCLR CLI tool) must be installed as a dotnet tool
# - .NET 8.0 or later must be installed

set -e

# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"

echo "Running typed.clj.checker tests under ClojureCLR..."

# Run tests using cljr with deps-clr.edn and cognitect test-runner
cd "$PROJECT_ROOT"
cljr -M:test "$@"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with script/test-clr and the cljr -M:test entry point, then inspect the dependency declarations in deps-clr.edn and the .gitlibs clone path shown in the logs. Reproduce the duplicate cloning of clr.tools.reader and determine whether the dependency resolution run can avoid the existing-directory failure; done means the CLR test command completes successfully without manual cache cleanup.

Written by the indexing model from the issue text.

Assessment

Tech stack
git
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.