I have a script I have been working on which I'm now trying to put in a container. The script was working just fine when I ran it directly, but in the container (based on python:3.12.0), something very strange is happening when I try to construct my Repository instance.
Relevant part of my code:
import os
import pygit2
# ... use argparse to obtain arguments from commandline into 'args' variable ...
GIT_WORKING_COPY = os.path.expanduser(args.repo_path)
print(f'Working copy: {GIT_WORKING_COPY}')
if not os.path.isdir(GIT_WORKING_COPY):
raise Exception(f'Working copy {GIT_WORKING_COPY} does not exist')
print(f'Source branch: {args.source_branch}')
print(f'Target branch: {args.target_branch}')
repo = pygit2.Repository(GIT_WORKING_COPY)
But when I execute the container with docker run, passing the relevant parameters, the output I get is:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/app/incremental_sync/incremental_sync.py", line 29, in <module>
repo = pygit2.Repository(GIT_WORKING_COPY)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pygit2/repository.py", line 1606, in __init__
path_backend = init_file_backend(path, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_pygit2.GitError: Repository not found at dgithub/dgithub/dgithub/d
Working copy: /github/workspace
Source branch: main
Target branch: repo-rewrite/main
Somehow my GIT_WORKING_COPY var - which the output shows is fine as /github/workspace - is getting transformed to dgithub/dgithub/dgithub/d inside init_file_backend.
Any idea what I'm doing wrong? I'm using git=1:2.39.2-1.1 libgit2-dev=1.5.1+ds-1 and pygit2==1.11.1 (as newer libgit2-dev packages don't seem to be available for this container).
I have a script I have been working on which I'm now trying to put in a container. The script was working just fine when I ran it directly, but in the container (based on
python:3.12.0
), something very strange is happening when I try to construct myRepository
instance.Relevant part of my code:
But when I execute the container with
docker run
, passing the relevant parameters, the output I get is:Somehow my
GIT_WORKING_COPY
var - which the output shows is fine as/github/workspace
- is getting transformed todgithub/dgithub/dgithub/d
insideinit_file_backend
.Any idea what I'm doing wrong? I'm using
git=1:2.39.2-1.1 libgit2-dev=1.5.1+ds-1
andpygit2==1.11.1
(as newer libgit2-dev packages don't seem to be available for this container).