Invalid character in Windows template filenames · Issue #1 · gahjelle/template-aoc-python (original) (raw)

Great idea and really cool tutorial - thanks so much for this.

When I try to use this template on Windows using copier, I'm getting the following error:

C:\Users\gregorma\Desktop>copier gh:gahjelle/template-aoc-python foo2
Traceback (most recent call last):
  File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\gregorma\.local\bin\copier.exe\__main__.py", line 7, in <module>
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\plumbum\cli\application.py", line 629, in run
    inst, retcode = subapp.run(argv, exit=False)
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\plumbum\cli\application.py", line 624, in run
    retcode = inst.main(*tailargs)
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\copier\cli.py", line 38, in _wrapper
    return method(*args, **kwargs)
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\copier\cli.py", line 252, in main
    self.parent._copy(template_src, destination_path)
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\copier\cli.py", line 173, in _copy
    return copy(
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\copier\main.py", line 133, in copy
    conf = make_config(**locals())
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\copier\config\factory.py", line 96, in make_config
    src_path = vcs.clone(repo, vcs_ref or "HEAD")
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\copier\vcs.py", line 92, in clone
    git("checkout", ref)
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\plumbum\commands\base.py", line 99, in __call__
    return self.run(args, **kwargs)[1]
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\plumbum\commands\base.py", line 240, in run
    return p.run()
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\plumbum\commands\base.py", line 201, in runner
    return run_proc(p, retcode, timeout)
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\plumbum\commands\processes.py", line 322, in run_proc
    return _check_process(proc, retcode, timeout, stdout, stderr)
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\plumbum\commands\processes.py", line 24, in _check_process
    proc.verify(retcode, timeout, stdout, stderr)
  File "C:\Users\gregorma\.local\pipx\venvs\copier\lib\site-packages\plumbum\machines\base.py", line 28, in verify
    raise ProcessExecutionError(
plumbum.commands.processes.ProcessExecutionError: Unexpected exit code: 1
Command line: | 'C:\Program Files\Git\cmd\git.exe' checkout HEAD
Stderr:       | error: invalid path 'src/[[year]]/[[puzzle_dir]]/aoc[[year]][['%02d'|format(day)]].py.tmpl'
              | error: invalid path 'src/[[year]]/[[puzzle_dir]]/test_aoc[[year]][['%02d'|format(day)]].py.tmpl'

From what I can tell, it doesn't accept the pipe character as a valid character in a Windows filename (although I'm not totally sure of this). If I replace [['%02d'|format(day)]] with [[formatted_day]] and put an entry for [[formatted_day]] in the copier.yml file, it seems to work fine. Here's an example of that: https://github.com/grovduck/test-template.

Please let me know if I'm doing something incorrectly - it's my first time using copier!