Skip to content

Instructions for use with copier and cruft #556

@jsdodge

Description

@jsdodge

I just tried to follow the instructions in the README and encountered errors.

copier

I entered:

uv tool install copier --with copier-templates-extensions
copier copy gh:scientific-python/cookie test-scipy-cookie --trust --vcs-ref=HEAD

This installed copier (v. 9.5.0), then produced the following error:

Traceback (most recent call last):
  File "/Users/jsd/.local/bin/copier", line 10, in <module>
    sys.exit(copier_app_run())
             ^^^^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/plumbum/cli/application.py", line 640, in run
    inst, retcode = subapp.run(argv, exit=False)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/plumbum/cli/application.py", line 635, in run
    retcode = inst.main(*tailargs)
              ^^^^^^^^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier/cli.py", line 281, in main
    return _handle_exceptions(inner)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier/cli.py", line 70, in _handle_exceptions
    method()
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier/cli.py", line 272, in inner
    with self._worker(
         ^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier/main.py", line 254, in __exit__
    raise value
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier/cli.py", line 279, in inner
    worker.run_copy()
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier/main.py", line 950, in run_copy
    self._ask()
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier/main.py", line 505, in _ask
    system=self._system_render_context(),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier/main.py", line 385, in _system_render_context
    "answers_file": self.answers_relpath,
                    ^^^^^^^^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier/main.py", line 582, in answers_relpath
    return Path(template.render(**self.answers.combined))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/jinja2/environment.py", line 1290, in render
    ctx = self.new_context(dict(*args, **kwargs))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/jinja2/environment.py", line 1388, in new_context
    return new_context(
           ^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/jinja2/runtime.py", line 117, in new_context
    return environment.context_class(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jsd/.local/share/uv/tools/copier/lib/python3.12/site-packages/copier_templates_extensions/extensions/context.py", line 23, in __init__
    parent.update(extension_self.hook(parent))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/var/folders/lp/_hycnw992kl1_s_4p43q52jc0000gn/T/copier.vcs.clone.f4s2or_l/helpers/extensions.py", line 10, in hook
KeyError: 'project_name'

Cookiecutter

I entered:

uv tool install cookiecutter
cookiecutter gh:scientific-python/cookie

This worked as expected.

Cruft

I entered:

uv tool install cruft
cruft create gh:scientific-python/cookie

This installed cruft (v. 2.16.0), then produced the following error:

╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ Unable to initialize the cookiecutter using gh:scientific-python/cookie!     │
│ Failed to clone the repo. stderr: 'Cloning into                              │
│ '/var/folders/lp/_hycnw992kl1_s_4p43q52jc0000gn/T/tmpi3vm5nqm'...            │
│ ssh: Could not resolve hostname gh: nodename nor servname provided, or not   │
│ known                                                                        │
│ fatal: Could not read from remote repository.                                │
│                                                                              │
│ Please make sure you have the correct access rights                          │
│ and the repository exists.                                                   │
│ '                                                                            │
╰──────────────────────────────────────────────────────────────────────────────╯

Full URL instead of gh

I also tried replacing the gh:scientific-python/cookie with https://github.com/scientific-python/cookie. This resolved the error with Cruft, but not with Copier.

Let me know if any other information would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions