← Back to issue list

`version: git` does not work in core24

View original Github issue

Metadata

Project
snapcraft
Number
#4805
Type
issue
State
closed
Author
mr-cal
Labels
—
Created
Updated
Closed

Current evaluation

version: git failed on core24 because git was missing. Fixed by merging PR #5149 (commit c7d11ac65), which bundles a git binary as craft.git in $SNAP/libexec/snapcraft, with new spread tests.

Resolution: closed resolved

Reason: Maintainer mr-cal closed the issue after PR #5149 was merged as commit c7d11ac65 ("build(snap): add git as craft.git to snapcraft"), bundling git at libexec/snapcraft/craft.git and adding core24 spread tests; the fix ships in the core24 snap.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description `version: git` does not work for core24 snaps because `git` is not installed and fails when calling [this](https://github.com/canonical/craft-parts/blob/14d8f7a4ea0fe3502deaa97f699212e61c15e4b4/craft_parts/sources/git_source.py#L78) craft-parts function. One possible solution is to install it via craft-application [here](https://github.com/canonical/craft-application/blob/309aa73b39bd94e3cfe64a7148cb4e75bdb47308/craft_application/services/provider.py#L163) or let craft-parts decide if it needs to be installed. Another is to use `pygit2` in craft-parts instead of `subprocess.run(["git", ...`. ### To Reproduce snapcraft pack ### Environment n/a ### snapcraft.yaml ```shell name: test-snap version: git summary: test description: test grade: devel confinement: devmode base: core24 parts: my-part: plugin: nil ``` ### Relevant log output ```shell 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:38.588 remove directory /root/parts/my-part/build 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:38.593 Executing PosixPath('/root/parts/my-part/run/build.sh') 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.714 Staging my-part 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.715 execute action my-part:Action(part_name='my-part', step=Step.STAGE, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.734 Priming my-part 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.736 execute action my-part:Action(part_name='my-part', step=Step.PRIME, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.754 patch_elf: not enabled for part 'my-part' 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.756 Setting up Package 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.757 Update project variables: {'version': 'git', 'grade': 'devel'} 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.758 Determining the version from the project repo (version: git). 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.762 snapcraft internal error: FileNotFoundError(2, 'No such file or directory') 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.782 Traceback (most recent call last): 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.783 File "/snap/snapcraft/11694/lib/python3.10/site-packages/craft_application/application.py", line 524, in run 2024-05-10 08:11:40.414 :: 2024-05-10 08:11:39.783 return_code = dispatcher.run() or 0 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.784 File "/snap/snapcraft/11694/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.784 return self._loaded_command.run(self._parsed_command_args) 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.784 File "/snap/snapcraft/11694/lib/python3.10/site-packages/craft_application/commands/base.py", line 196, in run 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.785 result = self._run(parsed_args, **kwargs) or result 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.785 File "/snap/snapcraft/11694/lib/python3.10/site-packages/snapcraft/commands/lifecycle.py", line 82, in _run 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.785 self._services.package.write_metadata(self._services.lifecycle.prime_dir) 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.786 File "/snap/snapcraft/11694/lib/python3.10/site-packages/snapcraft/services/package.py", line 148, in write_metadata 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.786 self.metadata.to_yaml_file(meta_dir / "snap.yaml") 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.786 File "/snap/snapcraft/11694/lib/python3.10/site-packages/snapcraft/services/package.py", line 181, in metadata 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.787 return snap_yaml.get_metadata_from_project( 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.787 File "/snap/snapcraft/11694/lib/python3.10/site-packages/snapcraft/meta/snap_yaml.py", line 482, in get_metadata_from_project 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.787 version = process_version(project.version) 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.788 File "/snap/snapcraft/11694/lib/python3.10/site-packages/snapcraft/utils.py", line 477, in process_version 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.788 new_version = GitSource.generate_version() 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.788 File "/snap/snapcraft/11694/lib/python3.10/site-packages/craft_parts/sources/git_source.py", line 78, in generate_version 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.789 subprocess.check_output( 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.789 File "/snap/snapcraft/11694/usr/lib/python3.10/subprocess.py", line 421, in check_output 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.789 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.790 File "/snap/snapcraft/11694/usr/lib/python3.10/subprocess.py", line 503, in run 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.790 with Popen(*popenargs, **kwargs) as process: 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.790 File "/snap/snapcraft/11694/usr/lib/python3.10/subprocess.py", line 971, in __init__ 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.790 self._execute_child(args, executable, preexec_fn, close_fds, 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.790 File "/snap/snapcraft/11694/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.791 raise child_exception_type(errno_num, err_msg, err_filename) 2024-05-10 08:11:40.415 :: 2024-05-10 08:11:39.791 FileNotFoundError: [Errno 2] No such file or directory: 'git' 2024-05-10 08:11:40.416 Executing on host: lxc --project snapcraft config device show local:snapcraft-test-snap-on-amd64-for-amd64-80094658 2024-05-10 08:11:40.536 Executing on host: lxc --project snapcraft config device remove local:snapcraft-test-snap-on-amd64-for-amd64-80094658 disk-/root/project 2024-05-10 08:11:40.691 Executing on host: lxc --project snapcraft stop local:snapcraft-test-snap-on-amd64-for-amd64-80094658 2024-05-10 08:11:45.269 Failed to execute snapcraft in instance. 2024-05-10 08:11:45.274 Traceback (most recent call last): 2024-05-10 08:11:45.274 File "/snap/snapcraft/11694/lib/python3.10/site-packages/craft_application/application.py", line 366, in run_managed 2024-05-10 08:11:45.274 instance.execute_run( # pyright: ignore[reportUnknownMemberType,reportUnknownVariableType] 2024-05-10 08:11:45.274 File "/snap/snapcraft/11694/lib/python3.10/site-packages/craft_providers/lxd/lxd_instance.py", line 293, in execute_run 2024-05-10 08:11:45.274 return self.lxc.exec( 2024-05-10 08:11:45.275 File "/snap/snapcraft/11694/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 387, in exec 2024-05-10 08:11:45.275 return runner(final_cmd, timeout=timeout, check=check, **kwargs) 2024-05-10 08:11:45.275 File "/snap/snapcraft/11694/usr/lib/python3.10/subprocess.py", line 526, in run 2024-05-10 08:11:45.275 raise CalledProcessError(retcode, process.args, 2024-05-10 08:11:45.275 subprocess.CalledProcessError: Command '['lxc', '--project', 'snapcraft', 'exec', 'local:snapcraft-test-snap-on-amd64-for-amd64-80094658', '--cwd', '/root/project', '--', 'env', 'CRAFT_MANAGED_MODE=1', 'DEBIAN_FRONTEND=noninteractive', 'DEBCONF_NONINTERACTIVE_SEEN=true', 'DEBIAN_PRIORITY=critical', 'CRAFT_PLATFORM=amd64', 'CRAFT_VERBOSITY_LEVEL=TRACE', 'snapcraft', 'pack', '--verbosity=trace']' returned non-zero exit status 70. 2024-05-10 08:11:45.275 2024-05-10 08:11:45.275 The above exception was the direct cause of the following exception: 2024-05-10 08:11:45.275 Traceback (most recent call last): 2024-05-10 08:11:45.275 File "/snap/snapcraft/11694/lib/python3.10/site-packages/craft_application/application.py", line 520, in run 2024-05-10 08:11:45.275 self.run_managed(platform, build_for) 2024-05-10 08:11:45.275 File "/snap/snapcraft/11694/lib/python3.10/site-packages/craft_application/application.py", line 373, in run_managed 2024-05-10 08:11:45.275 raise craft_providers.ProviderError( 2024-05-10 08:11:45.275 craft_providers.errors.ProviderError: Failed to execute snapcraft in instance. 2024-05-10 08:11:45.275 Full execution log: '/home/developer/.local/state/snapcraft/log/snapcraft-20240510-081050.680381.log' ``` ### Additional context _No response_

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved version: git failed on core24 because git was missing. Fixed by merging PR #5149 (commit c7d11ac65), which bundles a git binary as craft.git in $SNAP/libexec/snapcraft, with new spread tests.
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #5149 (c7d11ac65), which bundled Git as craft.git so core24 builds can derive versions with version: git.
stealth/space-bunny-alpha — closed resolved Fixed by merging #5149 (c7d11ac65), which bundled Git as craft.git so Craft libraries can run Git-dependent operations.
qwen/qwen3.6-35b-a3b — — Fixed by bundling git in snapcraft via PR #5149, resolving the core24 build failure when using version: git. The issue was closed after maintainer confirmation.
qwen/qwen3.6-35b-a3b — — Resolved by merging pull request #5149, which bundles git into snapcraft. This ensures the git binary is available for core24 version generation, fixing the reported failure.
qwen/qwen3.6-35b-a3b — — Resolved by bundling git in snapcraft via PR #5149, fixing the core24 version git build failure.
qwen3.6-35b-a3b-mtp-q6 — — Resolved by bundling git in snapcraft via PR #5149, fixing the core24 build failure when using version: git.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/snapcraft#5149 (confidence 97%)

    Merged PR adding git as craft.git for CRAFT-3547; maintainer's closing comment cites it directly.

Related issues

Issue Project State Summary Similarity
#4944 Install `git` inside core24 build environments snapcraft closed Git was bundled for core24 build environments by merged PR #5149 (commit c7d11ac65), making it available as craft.git on Snapcraft's build PATH.
81%
#4740 `package-repositories` fail with the core24 base due to missing packages snapcraft closed Fixed in merged PR #4754 (commit 712626448) and released in Snapcraft 8.2.1: core24 remote builds now install GPG/dirmngr before configuring package repositories.
70%