Git with Samba on Ubuntu: "Unlink of file"

Viewed 707

My configuration:

  • remote repository on Gitlab.

  • Windows 10 machine with git (v. 2.25.1.windows.1)

  • Linux machine (Ubuntu) for local repositories (S:) with Samba (v. 4.11.6-Ubuntu)

The problem

From the Windows 10 machine CLI:

git clone -v --recurse-submodules --progress --verbose "https://gitlab.com/my-org/my-project.git" "S:/workspace/my-project/code"

I'm getting this error:

POST git-upload-pack (175 bytes)
remote: Enumerating objects: 1591, done.
remote: Counting objects: 100% (1591/1591), done.
remote: Compressing objects: 100% (1259/1259), done.
remote: Total 1591 (delta 318), reused 1543 (delta 270), pack-reused 0
Receiving objects: 100% (1591/1591), 6.60 MiB | 5.46 MiB/s, done.
Resolving deltas: 100% (318/318), done.

Unlink of file 'assets/main/packs/fancybox' failed. Should I try again? (y/n)

Troubleshooting

The problem is not always related to the same directory (in this example: "fancybox"). But it always occurs after the download is complete (100%)

From my Windows machine, with ProcessExplorer, I don't see any process blocking that folder. Likewise, the same from the Linux machine with Samba.

This is my smbstatus -L:

28971  65534  DENY_NONE  0x120089    RDONLY  LEASE(RWH)  /home/htdocs   workspace/my-project/code/.git/objects/pack/pack-3f0aa70acd802c42ee978f95bc62f61f24dc07d6.idx
28971  65534  DENY_NONE  0x12019f    RDWR    LEASE(RWH)  /home/htdocs   workspace/my-project/code/.git/index.lock
28971  65534  DENY_NONE  0x120089    RDONLY  LEASE(RWH)  /home/htdocs   workspace/my-project/code/.git/objects/pack/pack-3f0aa70acd802c42ee978f95bc62f61f24dc07d6.pack

On:

Unlink of file 'assets/main/packs/fancybox' failed. Should I try again? (y/n)

I tried to unlock this locked folder:

  • to assign permissions 777 to all respository
  • to kill the Samba process 28971 about my folder

but git keeps asking me if i want to try again :-(

I also tried setting up to have multiple debug messages:

GIT_CURL_VERBOSE = 2

but I didn't get the info I need.

This problem occurs to me and to another user. While to another colleague (same configuration), never.

In my office, for everything else, the network works well: we have no problems for copying, moving files from Win to Linux machine on the network.

Some idea?

1 Answers

A bit late, but I encountered this issue too and after some transversal research, I found out what is (at least one of) the cause of such weird behavior.

SMB has a cache whose default settings are too much aggressive for GIT, which during checkout or clones needs to create a lot of consecutive files. Please see below link:

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-7/ff686200(v=ws.10)#details

Although this article refers to older versions of Windows, everything is still valid for latest Windows 10 Builds.

So, at the expense of some traffic increase between the local machine and the one where the samba share resides, GIT can work in a solid and stable way.

You can disable such cache by directly creating a registry key:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Lanmanworkstation\Parameters
[DWORD] FileInfoCacheLifetime = 0
[DWORD] DirectoryCacheLifetime = 0

Or by using Powershell Admin

Set-SmbClientConfiguration -DirectoryCacheLifetime 0
Set-SmbClientConfiguration -FileInfoCacheLifetime 0
Related