copier-org / copier

Library and command-line utility for rendering projects templates.
https://readthedocs.org/projects/copier/
MIT License
2.07k stars 182 forks source link

Copier 9.4.x not working in debian:bullseye slim images #1837

Closed ap-wtioit closed 1 month ago

ap-wtioit commented 1 month ago

Describe the problem

git 2.30.2 (provided in debian bullseye) does not support --path-format=absolute for git rev-parse.

docker run --rm debian:bullseye-slim bash -c 'set -x; apt update && apt install git -y; git --version; git init .; git -C . rev-parse --git-path objects; git -C . rev-parse --path-format=absolute --git-path objects'

...
+ git --version
git version 2.30.2
+ git init .
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /.git/
+ git -C . rev-parse --git-path objects
.git/objects
+ git -C . rev-parse --path-format=absolute --git-path objects
--path-format=absolute
.git/objects

docker run --rm ubuntu:24.04 bash -c 'set -x; apt update && apt install git -y; git --version; git init .; git -C . rev-parse --git-path objects; git -C . rev-parse --path-format=absolute --git-path objects'

...
+ git --version
git version 2.43.0
+ git init .
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /.git/
+ git -C . rev-parse --git-path objects
.git/objects
+ git -C . rev-parse --path-format=absolute --git-path objects
/.git/objects

This leads to the following issues when running copier update -f --UNSAFE:

Traceback (most recent call last):
  File "/home/copier/.local/bin/copier", line 8, in <module>
    sys.exit(copier_app_run())
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/cli/application.py", line 640, in run
    inst, retcode = subapp.run(argv, exit=False)
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/cli/application.py", line 635, in run
    retcode = inst.main(*tailargs)
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/cli.py", line 425, in main
    return _handle_exceptions(inner)
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/cli.py", line 70, in _handle_exceptions
    method()
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/cli.py", line 423, in inner
    worker.run_update()
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 237, in __exit__
    raise value
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/cli.py", line 423, in inner
    worker.run_update()
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 914, in run_update
    self._apply_update()
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/copier/main.py", line 961, in _apply_update
    files_removed = git(
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/commands/base.py", line 115, in __call__
    return self.run(args, **kwargs)[1]
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/commands/base.py", line 254, in run
    return p.run()
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/commands/base.py", line 217, in runner
    return run_proc(p, retcode, timeout)
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/commands/processes.py", line 330, in run_proc
    return _check_process(proc, retcode, timeout, stdout, stderr)
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/commands/processes.py", line 19, in _check_process
    proc.verify(retcode, timeout, stdout, stderr)
  File "/home/copier/.local/share/pipx/venvs/copier/lib/python3.9/site-packages/plumbum/machines/base.py", line 29, in verify
    raise ProcessExecutionError(
plumbum.commands.processes.ProcessExecutionError: Unexpected exit code: 128
Command line: | /usr/bin/git diff-tree -r --diff-filter=D --name-only HEAD e570b55502d1798be198c744d7ecc6a8fa62cd77
Stderr:       | fatal: bad object e570b55502d1798be198c744d7ecc6a8fa62cd77

Template

https://github.com/Tecnativa/doodba-copier-template

To Reproduce

  1. Run copier with git 2.30.2 on debian bullseye

Logs

No response

Expected behavior

Copier 9.4.x should run fine with git 2.30.2.

Screenshots/screencasts/logs

No response

Operating system

Linux

Operating system distribution and version

debian bulleye

Copier version

copier 9.4.1

Python version

Python 3.9

Installation method

pipx+pypi

Additional context

No response

ap-wtioit commented 1 month ago

This argument should be only used if supported: https://github.com/copier-org/copier/blob/master/copier/tools.py#L238 or use os.path.abspath to make path absolute.