Skip to content

Issue with too many files in (ignored) .venv #2244

@makkus

Description

@makkus

Describe the problem

I'm having an issue with a project that has a large virtual env, and the .venv folder lives within the project folder. .venv is ignored in both copier.yaml & .gitignore. I also tried to not ignore the .venv folder in the copier.yaml file and only rely on .gitignore, but that also didn't help.

The issue is that the generated git apply command becomes too long with all the files in the .venv directory being excluded separately (traceback below).

I've created an example project (needs uv installed) to make it easy to reproduce the issue (although not sure if other OSs than my Fedora might have other limits with how long arguments to a command can be):

https://github.com/makkus/copier_issue

Note: I've installed copier using pixi, but couldn't select that below. Don't think it matters though.

Template

https://github.com/makkus/copier_issue

To Reproduce

copier copy --vcs-ref=HEAD gh:makkus/copier_issue test_template
cd test_template && git init && git add .* * && git commit -m 'chore: initial commit'
copier update --vcs-ref=HEAD  # works fine
uv run python main.py
copier update --vcs-ref=HEAD  # raises error

Logs

Traceback (most recent call last):
  File "/home/markus/.pixi/envs/copier/bin/copier", line 10, in <module>
    sys.exit(CopierApp.run())
             ~~~~~~~~~~~~~^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/cli/application.py", line 640, in run
    inst, retcode = subapp.run(argv, exit=False)
                    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/cli/application.py", line 635, in run
    retcode = inst.main(*tailargs)
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/copier/_cli.py", line 428, in main
    return _handle_exceptions(inner)
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/copier/_cli.py", line 71, in _handle_exceptions
    method()
    ~~~~~~^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/copier/_cli.py", line 418, in inner
    with self._worker(
         ~~~~~~~~~~~~^
        dst_path=destination_path,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
        overwrite=True,
        ^^^^^^^^^^^^^^^
    ) as worker:
    ^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/copier/_main.py", line 271, in __exit__
    raise value
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/copier/_cli.py", line 426, in inner
    worker.run_update()
    ~~~~~~~~~~~~~~~~~^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/copier/_main.py", line 95, in _wrapper
    return func(*args, **kwargs)
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/copier/_main.py", line 1124, in run_update
    self._apply_update()
    ~~~~~~~~~~~~~~~~~~^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/copier/_main.py", line 1293, in _apply_update
    (apply_cmd << diff)(retcode=None)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/commands/base.py", line 115, in __call__
    return self.run(args, **kwargs)[1]
           ~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/commands/base.py", line 253, in run
    with self.bgrun(args, **kwargs) as p:
         ~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/commands/base.py", line 209, in bgrun
    p = self.popen(args, **kwargs)
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/commands/base.py", line 563, in popen
    return self.cmd.popen(args, **kwargs)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/commands/base.py", line 334, in popen
    return self.cmd.popen(self.args + list(args), **kwargs)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/commands/base.py", line 361, in popen
    return self.cmd.popen(
           ~~~~~~~~~~~~~~^
        args,
        ^^^^^
    ...<2 lines>...
        **kwargs,
        ^^^^^^^^^
    )
    ^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/machines/local.py", line 116, in popen
    return self.machine._popen(
           ~~~~~~~~~~~~~~~~~~~^
        self.executable,
        ^^^^^^^^^^^^^^^^
    ...<3 lines>...
        **kwargs,
        ^^^^^^^^^
    )
    ^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/machines/local.py", line 298, in _popen
    proc = PlumbumLocalPopen(
        argv,
    ...<6 lines>...
        **kwargs,
    )  # bufsize = 4096
  File "/home/markus/.pixi/envs/copier/lib/python3.13/site-packages/plumbum/machines/local.py", line 30, in __init__
    self._proc = Popen(*args, **kwargs)  # pylint: disable=consider-using-with
                 ~~~~~^^^^^^^^^^^^^^^^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/subprocess.py", line 1039, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                        pass_fds, cwd, env,
                        ^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
                        gid, gids, uid, umask,
                        ^^^^^^^^^^^^^^^^^^^^^^
                        start_new_session, process_group)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/markus/.pixi/envs/copier/lib/python3.13/subprocess.py", line 1972, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 7] Argument list too long: '/home/markus/.pixi/bin/git'

Expected behavior

There would be no error, even with a .venv (or other ignored/excluded folder for that matter) that has tons of files in it.

Screenshots/screencasts/logs

No response

Operating system

Linux

Operating system distribution and version

Fedora 42

Copier version

9.8.0

Python version

CPython 3.13.5

Installation method

uvx+pypi

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriageTrying to make sure if this is valid or not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions