canonical / snapcraft

Package, distribute, and update any app for Linux and IoT.
https://snapcraft.io
GNU General Public License v3.0
1.18k stars 444 forks source link

`version: git` does not work in core24 #4805

Open mr-cal opened 5 months ago

mr-cal commented 5 months ago

Bug Description

version: git does not work for core24 snaps because git is not installed and fails when calling this craft-parts function.

One possible solution is to install it via craft-application here 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

name: test-snap
version: git
summary: test
description: test

grade: devel
confinement: devmode

base: core24

parts:
  my-part:
    plugin: nil

Relevant log output

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

syncronize-issues-to-jira[bot] commented 5 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2909.

This message was autogenerated