microsoft/VFSForGit

"Blocked index rename outside the lock" when running Git commands after mounting

winstliu opened this issue · 2 comments

gvfs mount repo
cd repo\src
gvfs status repo # => Mount status: Ready, GVFS Lock: Free
git checkout -- . # => fatal: unable to write new index file

In the logs I get Mount {"Message":"Virtual repo is ready"} followed by a bunch of:

NotifyPreRenameHandler_BlockedIndexRename {"Area":"WindowsFileSystemVirtualizer","relativePath":".git\\index.lock","WarningMessage":"Blocked index rename outside the lock"}

Using Git-2.29.0.vfs.0.0-64-bit.exe and SetupGVFS.1.0.20296.6.exe.

Not sure what I'm doing wrong :(

More details:
I can only reproduce this when running noninteractively using a service account (through an Azure Pipelines self-hosted agent). The service account is an administrator.

When I run the same steps logged in as my own account (also an administrator), the checkout succeeds.

Figured this out while on a run:
The Azure Pipelines agent bundles its own version of Git, that it prepends to the PATH variable when running jobs! Since that Git isn't aware of VFS for Git, we get the errors above.

The fix:

gvfs mount repo
cd repo\src

# Ensure we use the Git that comes with VFS for Git and not the agent's bundled version!
$env:PATH = [Environment]::GetEnvironmentVariable("PATH", "Machine")
git checkout -- .