Skip to content

Unable to create file '.github/workflows/test_pages_build.yaml'. Error message: 'github' is undefined. #114

Closed
@cmungall

Description

@cmungall
Member

cruft create https://github.com/linkml/linkml-project-cookiecutter

gives:

 Unable to create file '.github/workflows/test_pages_build.yaml'. Error message: 'github' is undefined.

➜ repos cruft create https://github.com/linkml/linkml-project-cookiecutter
project_name [my-awesome-schema]: test123
github_org [my-org]:
project_description [This is the project description.]:
full_name [My Name]:
email [my-name@my-org.org]:
Select license:
1 - MIT
2 - BSD-3
3 - GNU GPL v3.0
4 - Apache Software License 2.0
Choose from 1, 2, 3, 4 [1]:
main_schema_class [Person]:
Select create_python_classes:
1 - Yes
2 - No
Choose from 1, 2 [1]:
Select use_schemasheets:
1 - No
2 - Yes
Choose from 1, 2 [1]:
google_sheet_id [1wVoaiFg47aT9YWNeRfTZ8tYHN8s8PAuDx5i2HUcDpvQ]:
google_sheet_tabs [personinfo enums]:
github_token_for_pypi_deployment [PYPI_PASSWORD]:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cookiecutter/gener │
│ ate.py:373 in generate_files │
│ │
│ 370 │ │ │ │ │ shutil.copymode(infile, outfile) │
│ 371 │ │ │ │ │ continue │
│ 372 │ │ │ │ try: │
│ ❱ 373 │ │ │ │ │ generate_file( │
│ 374 │ │ │ │ │ │ project_dir, infile, context, env, skip_if_file_exists │
│ 375 │ │ │ │ │ ) │
│ 376 │ │ │ │ except UndefinedError as err: │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ accept_hooks = True │ │
│ │ context = OrderedDict([('cookiecutter', OrderedDict([('project_name', │ │
│ │ 'test123'), ('__project_slug', 'test123'), ('github_org', │ │
│ │ 'my-org'), ('__source_path', 'src/test123/schema/test123.yaml'), │ │
│ │ ('project_description', 'This is the project description.'), │ │
│ │ ('full_name', 'My Name'), ('email', 'my-name@my-org.org'), │ │
│ │ ('__author', 'My Name my-name@my-org.org'), ('license', │ │
│ │ 'MIT'), ('main_schema_class', 'Person'), │ │
│ │ ('create_python_classes', 'Yes'), ('use_schemasheets', 'No'), │ │
│ │ ('google_sheet_id', │ │
│ │ '1wVoaiFg47aT9YWNeRfTZ8tYHN8s8PAuDx5i2HUcDpvQ'), │ │
│ │ ('google_sheet_tabs', 'personinfo enums'), │ │
│ │ ('__google_sheet_module', 'personinfo_enums'), │ │
│ │ ('github_token_for_pypi_deployment', 'PYPI_PASSWORD'), │ │
│ │ ('template', │ │
│ │ 'https://github.com/linkml/linkml-project-cookiecutter')]))]) │ │
│ │ copy_dirs = [] │ │
│ │ d = 'workflows' │ │
│ │ d
= '.github/workflows' │ │
│ │ delete_project_on_failure = True │ │
│ │ dirs = [] │ │
│ │ env = <cookiecutter.environment.StrictEnvironment object at │ │
│ │ 0x7fe1c02742e0> │ │
│ │ envvars = {} │ │
│ │ f = 'test_pages_build.yaml' │ │
│ │ files = [ │ │
│ │ │ 'deploy-docs.yaml', │ │
│ │ │ 'pypi-publish.yaml', │ │
│ │ │ 'main.yaml', │ │
│ │ │ 'test_pages_build.yaml' │ │
│ │ ] │ │
│ │ infile = '.github/workflows/test_pages_build.yaml' │ │
│ │ msg = "Unable to create file │ │
│ │ '.github/workflows/test_pages_build.yaml'" │ │
│ │ output_dir = '.' │ │
│ │ output_directory_created = True │ │
│ │ overwrite_if_exists = False │ │
│ │ project_dir = '/Users/cjm/repos/test123' │ │
│ │ render_dirs = [] │ │
│ │ repo_dir = PosixPath('/var/folders/nc/m4tx21912kv1b8nk3zzx9plr0000gn/T/tmp… │ │
│ │ root = './.github/workflows' │ │
│ │ skip_if_file_exists = False │ │
│ │ template_dir = '/var/folders/nc/m4tx21912kv1b8nk3zzx9plr0000gn/T/tmpujcf_x86/{… │ │
│ │ unrendered_dir = '/Users/cjm/repos/test123/./.github/workflows' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cookiecutter/gener │
│ ate.py:179 in generate_file │
│ │
│ 176 │ │ │ # information about syntax error location │
│ 177 │ │ │ exception.translated = False │
│ 178 │ │ │ raise │
│ ❱ 179 │ │ rendered_file = tmpl.render(**context) │
│ 180 │ │ │
│ 181 │ │ # Detect original file newline to output the rendered file │
│ 182 │ │ # note: newline='' ensures newlines are not converted │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ context = OrderedDict([('cookiecutter', OrderedDict([('project_name', │ │
│ │ 'test123'), ('__project_slug', 'test123'), ('github_org', 'my-org'), │ │
│ │ ('__source_path', 'src/test123/schema/test123.yaml'), │ │
│ │ ('project_description', 'This is the project description.'), │ │
│ │ ('full_name', 'My Name'), ('email', 'my-name@my-org.org'), │ │
│ │ ('__author', 'My Name my-name@my-org.org'), ('license', 'MIT'), │ │
│ │ ('main_schema_class', 'Person'), ('create_python_classes', 'Yes'), │ │
│ │ ('use_schemasheets', 'No'), ('google_sheet_id', │ │
│ │ '1wVoaiFg47aT9YWNeRfTZ8tYHN8s8PAuDx5i2HUcDpvQ'), ('google_sheet_tabs', │ │
│ │ 'personinfo enums'), ('__google_sheet_module', 'personinfo_enums'), │ │
│ │ ('github_token_for_pypi_deployment', 'PYPI_PASSWORD'), ('_template', │ │
│ │ 'https://github.com/linkml/linkml-project-cookiecutter')]))]) │ │
│ │ env = <cookiecutter.environment.StrictEnvironment object at 0x7fe1c02742e0> │ │
│ │ file_name_is_empty = False │ │
│ │ infile = '.github/workflows/test_pages_build.yaml' │ │
│ │ infile_fwd_slashes = '.github/workflows/test_pages_build.yaml' │ │
│ │ outfile = '/Users/cjm/repos/test123/.github/workflows/test_pages_build.yaml' │ │
│ │ outfile_tmpl = │ │
│ │ project_dir = '/Users/cjm/repos/test123' │ │
│ │ skip_if_file_exists = False │ │
│ │ tmpl = <Template '.github/workflows/test_pages_build.yaml'> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/jinja2/environment │
│ .py:1301 in render │
│ │
│ 1298 │ │ try: │
│ 1299 │ │ │ return self.environment.concat(self.root_render_func(ctx)) # type: ignore │
│ 1300 │ │ except Exception: │
│ ❱ 1301 │ │ │ self.environment.handle_exception() │
│ 1302 │ │
│ 1303 │ async def render_async(self, *args: t.Any, **kwargs: t.Any) -> str: │
│ 1304 │ │ """This works similar to :meth:render but returns a coroutine │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ args = () │ │
│ │ ctx = <Context {'range': <class 'range'>, 'dict': <class 'dict'>, 'lipsum': <function │ │
│ │ generate_lorem_ipsum at 0x7fe1d04ed280>, 'cycler': <class 'jinja2.utils.Cycler'>, │ │
│ │ 'joiner': <class 'jinja2.utils.Joiner'>, 'namespace': <class │ │
│ │ 'jinja2.utils.Namespace'>, 'random_ascii_string': <function │ │
│ │ RandomStringExtension.init..random_ascii_string at 0x7fe1902e3b80>, │ │
│ │ 'uuid4': <function UUIDExtension.init..uuid4 at 0x7fe1902e3ca0>, │ │
│ │ 'cookiecutter': OrderedDict([('project_name', 'test123'), ('__project_slug', │ │
│ │ 'test123'), ('github_org', 'my-org'), ('__source_path', │ │
│ │ 'src/test123/schema/test123.yaml'), ('project_description', 'This is the project │ │
│ │ description.'), ('full_name', 'My Name'), ('email', 'my-name@my-org.org'), │ │
│ │ ('__author', 'My Name my-name@my-org.org'), ('license', 'MIT'), │ │
│ │ ('main_schema_class', 'Person'), ('create_python_classes', 'Yes'), │ │
│ │ ('use_schemasheets', 'No'), ('google_sheet_id', │ │
│ │ '1wVoaiFg47aT9YWNeRfTZ8tYHN8s8PAuDx5i2HUcDpvQ'), ('google_sheet_tabs', 'personinfo │ │
│ │ enums'), ('__google_sheet_module', 'personinfo_enums'), │ │
│ │ ('github_token_for_pypi_deployment', 'PYPI_PASSWORD'), ('_template', │ │
│ │ 'https://github.com/linkml/linkml-project-cookiecutter')])} of │ │
│ │ '.github/workflows/test_pages_build.yaml'> │ │
│ │ kwargs = { │ │
│ │ │ 'cookiecutter': OrderedDict([('project_name', 'test123'), ('__project_slug', │ │
│ │ 'test123'), ('github_org', 'my-org'), ('__source_path', │ │
│ │ 'src/test123/schema/test123.yaml'), ('project_description', 'This is the project │ │
│ │ description.'), ('full_name', 'My Name'), ('email', 'my-name@my-org.org'), │ │
│ │ ('__author', 'My Name my-name@my-org.org'), ('license', 'MIT'), │ │
│ │ ('main_schema_class', 'Person'), ('create_python_classes', 'Yes'), │ │
│ │ ('use_schemasheets', 'No'), ('google_sheet_id', │ │
│ │ '1wVoaiFg47aT9YWNeRfTZ8tYHN8s8PAuDx5i2HUcDpvQ'), ('google_sheet_tabs', 'personinfo │ │
│ │ enums'), ('__google_sheet_module', 'personinfo_enums'), │ │
│ │ ('github_token_for_pypi_deployment', 'PYPI_PASSWORD'), ('_template', │ │
│ │ 'https://github.com/linkml/linkml-project-cookiecutter')]) │ │
│ │ } │ │
│ │ self = <Template '.github/workflows/test_pages_build.yaml'> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/jinja2/environment │
│ .py:936 in handle_exception │
│ │
│ 933 │ │ """ │
│ 934 │ │ from .debug import rewrite_traceback_stack │
│ 935 │ │ │
│ ❱ 936 │ │ raise rewrite_traceback_stack(source=source) │
│ 937 │ │
│ 938 │ def join_path(self, template: str, parent: str) -> str: │
│ 939 │ │ """Join a template with the parent. By default all the lookups are │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ rewrite_traceback_stack = <function rewrite_traceback_stack at 0x7fe19078b4c0> │ │
│ │ self = <cookiecutter.environment.StrictEnvironment object at │ │
│ │ 0x7fe1c02742e0> │ │
│ │ source = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ in top-level template code:10 │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/jinja2/environment │
│ .py:485 in getattr │
│ │
│ 482 │ │ Unlike :meth:getitem the attribute must be a string. │
│ 483 │ │ """ │
│ 484 │ │ try: │
│ ❱ 485 │ │ │ return getattr(obj, attribute) │
│ 486 │ │ except AttributeError: │
│ 487 │ │ │ pass │
│ 488 │ │ try: │
│ │
│ ╭───────────────────────────────────── locals ──────────────────────────────────────╮ │
│ │ attribute = 'ref' │ │
│ │ obj = Undefined │ │
│ │ self = <cookiecutter.environment.StrictEnvironment object at 0x7fe1c02742e0> │ │
│ ╰───────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
UndefinedError: 'github' is undefined

During handling of the above exception, another exception occurred:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cruft/_cli.py:107 │
│ in create │
│ │
│ 104 │ │ None, "--skip", show_default=False, help="Default files/pattern to skip on updat │
│ 105 │ ), │
│ 106 ) -> None: │
│ ❱ 107 │ _commands.create( │
│ 108 │ │ template_git_url, │
│ 109 │ │ output_dir=output_dir, │
│ 110 │ │ config_file=config_file, │
│ │
│ ╭─────────────────────────────────── locals ────────────────────────────────────╮ │
│ │ checkout = None │ │
│ │ config_file = None │ │
│ │ default_config = False │ │
│ │ directory = None │ │
│ │ extra_context = '{}' │ │
│ │ no_input = False │ │
│ │ output_dir = PosixPath('.') │ │
│ │ overwrite_if_exists = False │ │
│ │ skip = [] │ │
│ │ template_git_url = 'https://github.com/linkml/linkml-project-cookiecutter' │ │
│ ╰───────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cruft/_commands/ut │
│ ils/init.py:14 in wrapper │
│ │
│ 11 │ │ def decorator(f): │
│ 12 │ │ │ @wraps(f) │
│ 13 │ │ │ def wrapper(*args, **kwargs): │
│ ❱ 14 │ │ │ │ return f(*args, **kwargs) │
│ 15 │ │ │ │
│ 16 │ │ │ return wrapper │
│ 17 │
│ │
│ ╭────────────────────────────── locals ───────────────────────────────╮ │
│ │ args = ('https://github.com/linkml/linkml-project-cookiecutter',) │ │
│ │ f = <function create at 0x7fe19831f670> │ │
│ │ kwargs = { │ │
│ │ │ 'output_dir': PosixPath('.'), │ │
│ │ │ 'config_file': None, │ │
│ │ │ 'default_config': False, │ │
│ │ │ 'extra_context': {}, │ │
│ │ │ 'no_input': False, │ │
│ │ │ 'directory': None, │ │
│ │ │ 'checkout': None, │ │
│ │ │ 'overwrite_if_exists': False, │ │
│ │ │ 'skip': [] │ │
│ │ } │ │
│ ╰─────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cruft/_commands/cr │
│ eate.py:46 in create │
│ │
│ 43 │ │ │ ) │
│ 44 │ │ │
│ 45 │ │ project_dir = Path( │
│ ❱ 46 │ │ │ generate_files( │
│ 47 │ │ │ │ repo_dir=cookiecutter_template_dir, │
│ 48 │ │ │ │ context=context, │
│ 49 │ │ │ │ overwrite_if_exists=overwrite_if_exists, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ checkout = None │ │
│ │ config_file = None │ │
│ │ context = OrderedDict([('cookiecutter', OrderedDict([('project_name', │ │
│ │ 'test123'), ('__project_slug', 'test123'), ('github_org', │ │
│ │ 'my-org'), ('__source_path', │ │
│ │ 'src/test123/schema/test123.yaml'), ('project_description', │ │
│ │ 'This is the project description.'), ('full_name', 'My │ │
│ │ Name'), ('email', 'my-name@my-org.org'), ('__author', 'My │ │
│ │ Name my-name@my-org.org'), ('license', 'MIT'), │ │
│ │ ('main_schema_class', 'Person'), ('create_python_classes', │ │
│ │ 'Yes'), ('use_schemasheets', 'No'), ('google_sheet_id', │ │
│ │ '1wVoaiFg47aT9YWNeRfTZ8tYHN8s8PAuDx5i2HUcDpvQ'), │ │
│ │ ('google_sheet_tabs', 'personinfo enums'), │ │
│ │ ('__google_sheet_module', 'personinfo_enums'), │ │
│ │ ('github_token_for_pypi_deployment', 'PYPI_PASSWORD'), │ │
│ │ ('_template', │ │
│ │ 'https://github.com/linkml/linkml-project-cookiecutter')]))… │ │
│ │ cookiecutter_template_dir = PosixPath('/var/folders/nc/m4tx21912kv1b8nk3zzx9plr0000gn/T… │ │
│ │ cookiecutter_template_dir_str = '/var/folders/nc/m4tx21912kv1b8nk3zzx9plr0000gn/T/tmpujcf_x… │ │
│ │ default_config = False │ │
│ │ directory = None │ │
│ │ extra_context = {} │ │
│ │ last_commit = '4e062ec2471c7110af2f2ae4fc4a016fcb188bd3' │ │
│ │ no_input = False │ │
│ │ output_dir = PosixPath('.') │ │
│ │ overwrite_if_exists = False │ │
│ │ repo = <git.repo.base.Repo │ │
│ │ '/var/folders/nc/m4tx21912kv1b8nk3zzx9plr0000gn/T/tmpujcf_x… │ │
│ │ skip = [] │ │
│ │ template_git_url = 'https://github.com/linkml/linkml-project-cookiecutter' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cookiecutter/gener │
│ ate.py:380 in generate_files │
│ │
│ 377 │ │ │ │ │ if delete_project_on_failure: │
│ 378 │ │ │ │ │ │ rmtree(project_dir) │
│ 379 │ │ │ │ │ msg = f"Unable to create file '{infile}'" │
│ ❱ 380 │ │ │ │ │ raise UndefinedVariableInTemplate(msg, err, context) │
│ 381 │ │
│ 382 │ if accept_hooks: │
│ 383 │ │ _run_hook_from_repo_dir( │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ accept_hooks = True │ │
│ │ context = OrderedDict([('cookiecutter', OrderedDict([('project_name', │ │
│ │ 'test123'), ('__project_slug', 'test123'), ('github_org', │ │
│ │ 'my-org'), ('__source_path', 'src/test123/schema/test123.yaml'), │ │
│ │ ('project_description', 'This is the project description.'), │ │
│ │ ('full_name', 'My Name'), ('email', 'my-name@my-org.org'), │ │
│ │ ('__author', 'My Name my-name@my-org.org'), ('license', │ │
│ │ 'MIT'), ('main_schema_class', 'Person'), │ │
│ │ ('create_python_classes', 'Yes'), ('use_schemasheets', 'No'), │ │
│ │ ('google_sheet_id', │ │
│ │ '1wVoaiFg47aT9YWNeRfTZ8tYHN8s8PAuDx5i2HUcDpvQ'), │ │
│ │ ('google_sheet_tabs', 'personinfo enums'), │ │
│ │ ('__google_sheet_module', 'personinfo_enums'), │ │
│ │ ('github_token_for_pypi_deployment', 'PYPI_PASSWORD'), │ │
│ │ ('template', │ │
│ │ 'https://github.com/linkml/linkml-project-cookiecutter')]))]) │ │
│ │ copy_dirs = [] │ │
│ │ d = 'workflows' │ │
│ │ d
= '.github/workflows' │ │
│ │ delete_project_on_failure = True │ │
│ │ dirs = [] │ │
│ │ env = <cookiecutter.environment.StrictEnvironment object at │ │
│ │ 0x7fe1c02742e0> │ │
│ │ envvars = {} │ │
│ │ f = 'test_pages_build.yaml' │ │
│ │ files = [ │ │
│ │ │ 'deploy-docs.yaml', │ │
│ │ │ 'pypi-publish.yaml', │ │
│ │ │ 'main.yaml', │ │
│ │ │ 'test_pages_build.yaml' │ │
│ │ ] │ │
│ │ infile = '.github/workflows/test_pages_build.yaml' │ │
│ │ msg = "Unable to create file │ │
│ │ '.github/workflows/test_pages_build.yaml'" │ │
│ │ output_dir = '.' │ │
│ │ output_directory_created = True │ │
│ │ overwrite_if_exists = False │ │
│ │ project_dir = '/Users/cjm/repos/test123' │ │
│ │ render_dirs = [] │ │
│ │ repo_dir = PosixPath('/var/folders/nc/m4tx21912kv1b8nk3zzx9plr0000gn/T/tmp… │ │
│ │ root = './.github/workflows' │ │
│ │ skip_if_file_exists = False │ │
│ │ template_dir = '/var/folders/nc/m4tx21912kv1b8nk3zzx9plr0000gn/T/tmpujcf_x86/{… │ │
│ │ unrendered_dir = '/Users/cjm/repos/test123/./.github/workflows' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
UndefinedVariableInTemplate: Unable to create file '.github/workflows/test_pages_build.yaml'. Error message: 'github' is undefined. Context: OrderedDict([('cookiecutter', OrderedDict([('project_name', 'test123'), ('__project_slug',
'test123'), ('github_org', 'my-org'), ('__source_path', 'src/test123/schema/test123.yaml'), ('project_description', 'This is the project description.'), ('full_name', 'My Name'), ('email', 'my-name@my-org.org'), ('__author', 'My Name
my-name@my-org.org'), ('license', 'MIT'), ('main_schema_class', 'Person'), ('create_python_classes', 'Yes'), ('use_schemasheets', 'No'), ('google_sheet_id', '1wVoaiFg47aT9YWNeRfTZ8tYHN8s8PAuDx5i2HUcDpvQ'), ('google_sheet_tabs',
'personinfo enums'), ('__google_sheet_module', 'personinfo_enums'), ('github_token_for_pypi_deployment', 'PYPI_PASSWORD'), ('_template', 'https://github.com/linkml/linkml-project-cookiecutter')]))])

Activity

cmungall

cmungall commented on Jun 18, 2024

@cmungall
MemberAuthor

I think this needs to be undone:

I think the intent is to have a jinja expression that is expanded at the time of github actions, in which case it needs escaped so it is not expanded at time of cruft create

added a commit that references this issue on Jun 18, 2024
b414054
added a commit that references this issue on Aug 18, 2024
16f16c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @cmungall@sujaypatil96

    Issue actions

      Unable to create file '.github/workflows/test_pages_build.yaml'. Error message: 'github' is undefined. · Issue #114 · linkml/linkml-project-cookiecutter