Repository navigation
Description
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) |> ignore10.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
-
Use a
paket.dependencieswith a git dependency, for example:source https://api.nuget.org/v3/index.json git https://github.com/ionide/ionide-fsgrammar.git master -
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
Seed the Paket git cache in CI
github-actions commentedon Oct 25, 2026
🤖 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,
fetchCacherunsgit init --bareandgit remote add --mirror=fetch origin <url>, then continues withremote update --prune.Add this agentic workflow to your repo
To install this agentic workflow, run
Fix git cache init when cache folder pre-exists (#4461)
fix(git): set up the git cache in place when its folder exists
build-stack: prime the Paket git cache for build-script
Bump Paket, Fable and Fantomas, drop the Paket git cache workaround