Skip to content

git dependencies fail to restore from a cold git cache since 11.0.0 (fetchCache runs after the lock creates the cache folder) #4461

Closed

Description

@nojaf

Description

Since 11.0.0, paket restore fails for a git dependency when the git cache in ~/.paket/git/db doesn't have that repository yet. A fresh CI agent always starts that way, so restore fails on every CI run.

The cause is #4407 (commit 59f1bb9). RemoteDownload now runs fetchCache inside RunInLockedAccessMode(repoCacheFolder, ...). RunInLockedAccessMode creates repoCacheFolder to hold its paket.processlock file. fetchCache then finds that the folder exists, skips git clone --mirror, and runs git remote set-url origin in an empty folder that isn't a git repository:

// RemoteDownload.fs
RunInLockedAccessMode(repoCacheFolder, (fun () -> Paket.Git.Handling.fetchCache repoCacheFolder cloneUrl; false))

// GitHandling.fs, fetchCache
if not (Directory.Exists repoCacheFolder) then   // always false now: the lock created the folder
    ... "clone --mirror " ...
else
    CommandHelper.runSimpleGitCommand repoCacheFolder ("remote set-url origin " + quote cloneUrl) |> ignore

10.3.1 doesn't contain the change. 11.0.0, 11.0.1 and 12.0.0-alpha002 fail. 8.0.3 restores the same repository fine from a cold cache.

This blocks the Ionide 8.0.0 release: ionide/ionide-vscode-fsharp#2181 moves the build to .NET 10, which needs Paket 11 or later to parse net10.0. Both CI jobs (Windows and macOS) fail on this.

Repro steps

  1. Use a paket.dependencies with a git dependency, for example:

    source https://api.nuget.org/v3/index.json
    git https://github.com/ionide/ionide-fsgrammar.git master
    
  2. Make sure the git cache is cold, for example with a fresh home directory:

    HOME=/tmp/coldhome dotnet paket restore --verbose
    

Expected behavior

Paket clones the repository into ~/.paket/git/db/ionide-fsgrammar and restores it, as 8.0.3 does.

Actual behavior

Paket failed with
-> Fetching the git cache at /tmp/coldhome/.paket/git/db/ionide-fsgrammar failed.
   Message: Could not run "git remote set-url origin "https://github.com/ionide/ionide-fsgrammar.git"".
   StackTrace:
        at Paket.Git.Handling.fetchCache(String repoCacheFolder, String cloneUrl) in /_//src/Paket.Core/Dependencies/GitHandling.fs:line 160
        at Paket.RemoteDownload.downloadRemoteFiles@218-2.Invoke(Unit unitVar0) in /_//src/Paket.Core/Dependencies/RemoteDownload.fs:line 218
        at Paket.Utils.RunInLockedAccessMode(String lockedFolder, FSharpFunc`2 lockedAction) in /_//src/Paket.Core/Common/Utils.fs:line 500

Afterwards ~/.paket/git/db/ionide-fsgrammar is an empty folder.

When restore runs through Paket.Restore.targets (for example dotnet build), MSBuild only shows The command "dotnet paket restore" exited with code 1, because the message is logged at normal verbosity.

Possible fix

In fetchCache, decide on "is it a git repository" rather than "does the folder exist". git clone --mirror refuses the folder because the lock file is already in it, but this works:

git init --bare
git remote add --mirror=fetch origin <cloneUrl>
git remote update --prune

I ran these by hand in a folder that contained a paket.processlock file. The mirror got master at the expected commit, and a file:// clone of it worked.

The fetchCache call at RemoteDownload.fs line 92 (paket update / outdated) goes through the same lock, so it has the same problem.

Known workarounds

Seed the cache before restore, so Paket finds an existing mirror:

git clone --mirror https://github.com/ionide/ionide-fsgrammar.git ~/.paket/git/db/ionide-fsgrammar

Activity

  1. added a commit that references this issue on Oct 23, 2026
  2. github-actions commented on Oct 25, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    Thanks for the detailed report and the suggested fix. I opened a draft PR that applies it: when the cache folder exists but isn't a git repository, fetchCache runs git init --bare and git remote add --mirror=fetch origin <url>, then continues with remote update --prune.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.
    Comment /repo-assist to run again

    Add this agentic workflow to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@b4e175bab6674279e0fe158f7dc877b77bc9d92f
    
  3. added a commit that references this issue on Nov 7, 2026
    9cc2f5a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions