Skip to content

Permission denied on config.lock when cloning in Docker under MacOS #1566

Closed
@mmajchrzycki

Description

@mmajchrzycki

Hi,
I found a bug related to the FileLock system. What I'm doing:

  1. In Ubuntu 20.04 running under Docker, I'm cloning the repository using clone_from.
  2. The directory that I'm cloning to is mounted under MacOS as follows:
    docker run --rm --interactive -v $PWD:/work --user $(id -u):$(id -g) /bin/bash
  3. Docker container is running with UID and GID of the MacOS

I'm getting this error:

Exception in thread my-repository:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/git/util.py", line 941, in _obtain_lock_or_raise
    fd = os.open(lock_file, flags, 0)
PermissionError: [Errno 13] Permission denied: '/work/repo/my-repository.git/.git/config.lock'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/app/clone-tool.py", line 124, in run
    git.Repo.clone_from(self.git_url, repo_dir)
  File "/usr/local/lib/python3.8/dist-packages/git/repo/base.py", line 1325, in clone_from
    return cls._clone(
  File "/usr/local/lib/python3.8/dist-packages/git/repo/base.py", line 1252, in _clone
    with repo.remotes[0].config_writer as writer:
  File "/usr/local/lib/python3.8/dist-packages/git/remote.py", line 1146, in config_writer
    writer = self.repo.config_writer()
  File "/usr/local/lib/python3.8/dist-packages/git/repo/base.py", line 604, in config_writer
    return GitConfigParser(self._get_config_path(config_level), read_only=False, repo=self)
  File "/usr/local/lib/python3.8/dist-packages/git/config.py", line 366, in __init__
    self._acquire_lock()
  File "/usr/local/lib/python3.8/dist-packages/git/config.py", line 385, in _acquire_lock
    self._lock._obtain_lock()
  File "/usr/local/lib/python3.8/dist-packages/git/util.py", line 951, in _obtain_lock
    return self._obtain_lock_or_raise()
  File "/usr/local/lib/python3.8/dist-packages/git/util.py", line 944, in _obtain_lock_or_raise
    raise IOError(str(e)) from e
OSError: [Errno 13] Permission denied: '/work/repo/my-repository.git/.git/config.lock'

The config.lock file as listed under Ubuntu:

$ ls -la
ls: cannot access 'config.lock': No such file or directory
total 144
drwxr-xr-x 14 501 dialout    448 Mar 24 13:42 .
drwxr-xr-x 18 501 dialout    576 Mar 24 13:42 ..
-rw-r--r--  1 501 dialout     23 Mar 24 13:42 HEAD
drwxr-xr-x  2 501 dialout     64 Mar 24 13:42 branches
-rw-r--r--  1 501 dialout    298 Mar 24 13:42 config
-?????????  ? ?   ?            ?            ? config.lock
-rw-r--r--  1 501 dialout     73 Mar 24 13:42 description
drwxr-xr-x 14 501 dialout    448 Mar 24 13:42 hooks
-rw-r--r--  1 501 dialout 122075 Mar 24 13:42 index
drwxr-xr-x  3 501 dialout     96 Mar 24 13:42 info
drwxr-xr-x  4 501 dialout    128 Mar 24 13:42 logs
drwxr-xr-x  4 501 dialout    128 Mar 24 13:42 objects
-rw-r--r--  1 501 dialout    114 Mar 24 13:42 packed-refs
drwxr-xr-x  5 501 dialout    160 Mar 24 13:42 refs

Also listed under MacOS:

$ ls -la
total 288
drwxr-xr-x  14 mmajchrzycki  staff     448 Mar 24 14:42 .
drwxr-xr-x  18 mmajchrzycki  staff     576 Mar 24 14:42 ..
-rw-r--r--   1 mmajchrzycki  staff      23 Mar 24 14:42 HEAD
drwxr-xr-x   2 mmajchrzycki  staff      64 Mar 24 14:42 branches
-rw-r--r--@  1 mmajchrzycki  staff     298 Mar 24 14:42 config
----------   1 mmajchrzycki  staff       0 Mar 24 14:42 config.lock
-rw-r--r--   1 mmajchrzycki  staff      73 Mar 24 14:42 description
drwxr-xr-x  14 mmajchrzycki  staff     448 Mar 24 14:42 hooks
-rw-r--r--   1 mmajchrzycki  staff  122075 Mar 24 14:42 index
drwxr-xr-x   3 mmajchrzycki  staff      96 Mar 24 14:42 info
drwxr-xr-x   4 mmajchrzycki  staff     128 Mar 24 14:42 logs
drwxr-xr-x   4 mmajchrzycki  staff     128 Mar 24 14:42 objects
-rw-r--r--   1 mmajchrzycki  staff     114 Mar 24 14:42 packed-refs

I will provide a minimum set-up (docker file and python script) to reproduce it later.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions