Copier crashes when trying to initialize an empty git repo inside the template.
Traceback (most recent call last):
File "/home/user/.local/bin/copier", line 10, in <module>
sys.exit(CopierApp.run())
~~~~~~~~~~~~~^^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/plumbum/cli/application.py", line 631, in run
inst, retcode = subapp.run(argv, exit=False)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/plumbum/cli/application.py", line 626, in run
retcode = inst.main(*tailargs)
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_cli.py", line 275, in main
return _handle_exceptions(inner)
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_cli.py", line 80, in _handle_exceptions
exit_code = method()
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_cli.py", line 257, in inner
run_copy(
~~~~~~~~^
template_src,
^^^^^^^^^^^^^
...<13 lines>...
skip_tasks=self.skip_tasks,
^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_main.py", line 1686, in run_copy
with Worker(
~~~~~~^
src_path=src_path,
^^^^^^^^^^^^^^^^^^
...<23 lines>...
skip_tasks=skip_tasks,
^^^^^^^^^^^^^^^^^^^^^^
) as worker:
^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_main.py", line 282, in __exit__
raise value
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_main.py", line 1713, in run_copy
worker.run_copy()
~~~~~~~~~~~~~~~^^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_main.py", line 104, in _wrapper
return func(*args, **kwargs)
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_main.py", line 1239, in run_copy
self._print_message(self.template.message_before_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/uv/python/cpython-3.13.5-linux-x86_64-gnu/lib/python3.13/functools.py", line 1026, in __get__
val = self.func(instance)
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_template.py", line 363, in message_before_copy
return self.config_data.get("message_before_copy", "")
^^^^^^^^^^^^^^^^
File "/home/user/.local/share/uv/python/cpython-3.13.5-linux-x86_64-gnu/lib/python3.13/functools.py", line 1026, in __get__
val = self.func(instance)
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_template.py", line 303, in config_data
result = filter_config(self._raw_config)[0]
^^^^^^^^^^^^^^^^
File "/home/user/.local/share/uv/python/cpython-3.13.5-linux-x86_64-gnu/lib/python3.13/functools.py", line 1026, in __get__
val = self.func(instance)
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_template.py", line 260, in _raw_config
for p in self.local_abspath.glob("copier.*")
^^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/uv/python/cpython-3.13.5-linux-x86_64-gnu/lib/python3.13/functools.py", line 1026, in __get__
val = self.func(instance)
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_template.py", line 571, in local_abspath
clone(
~~~~~^
self.url_expanded,
^^^^^^^^^^^^^^^^^^
self.ref or get_latest_tag(self.url_expanded, self.use_prereleases),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
location=str(self._temp_clone_path),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/copier/_vcs.py", line 237, in clone
git("--git-dir=.git", f"--work-tree={url_abspath}", "add", "-A")
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/plumbum/commands/base.py", line 110, in __call__
return self.run(args, **kwargs)[1]
~~~~~~~~^^^^^^^^^^^^^^^^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/plumbum/commands/base.py", line 249, in run
return p.run()
~~~~~^^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/plumbum/commands/base.py", line 212, in runner
return run_proc(p, retcode, timeout)
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/plumbum/commands/processes.py", line 330, in run_proc
return _check_process(proc, retcode, timeout, stdout, stderr)
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/plumbum/commands/processes.py", line 19, in _check_process
proc.verify(retcode, timeout, stdout, stderr)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/uv/tools/copier/lib/python3.13/site-packages/plumbum/machines/base.py", line 29, in verify
raise ProcessExecutionError(
getattr(self, "argv", None), self.returncode, stdout, stderr
)
plumbum.commands.processes.ProcessExecutionError: Unexpected exit code: 128
Command line: | /usr/bin/git --git-dir=.git --work-tree=/home/user/code/reit/python-package-template add -A
Stderr: | error: 'empty-repo/' does not have a commit checked out
| fatal: adding files failed
Copier would no crash in this situation.
This does not happen when running repo from the repo, e.g. copier copy --trust -r HEAD https://gitlab.ewi.tudelft.nl/reit/python-package-template ./empty-repo. It also doesn't matter if I run this inside the template repo, the empty repo or one level out, the error in the same.
Describe the problem
Copier crashes when trying to initialize an empty git repo inside the template.
Template
https://gitlab.ewi.tudelft.nl/reit/python-package-template/-/tree/clone-first?ref_type=heads
To Reproduce
copier copy --trust -r HEAD ./ ./empty_repo/Logs
Expected behavior
Copier would no crash in this situation.
Screenshots/screencasts/logs
No response
Operating system
Linux
Operating system distribution and version
Ubuntu 24.04
Copier version
9.15.1
Python version
3.13
Installation method
uvx+pypi
Additional context
This does not happen when running repo from the repo, e.g.
copier copy --trust -r HEAD https://gitlab.ewi.tudelft.nl/reit/python-package-template ./empty-repo. It also doesn't matter if I run this inside the template repo, the empty repo or one level out, the error in the same.