Failed to build gadget snap on VM, missing snapcraft.yaml

Hey, i am trying to build gadget snap on Azure Vm via Gitlab CI, one issue i run into, its complaining to not able to find snapcraft.yaml. (Tried to move it into snap folder gives same result)

Any Idea?

Versions

gitlab-runner@clp-dev-gitlab-runner-snap-build-weu:~/test/salto-pc$ snapcraft --version
snapcraft 8.3.2
gitlab-runner@clp-dev-gitlab-runner-snap-build-weu:~/test/salto-pc$ snap --version
snap    2.63+22.04ubuntu0.1
snapd   2.63+22.04ubuntu0.1
series  16
ubuntu  22.04
kernel  6.5.0-1025-azure

Debug Logs

gitlab-runner@clp-dev-gitlab-runner-snap-build-weu:~/test/salto-pc$ ls -al
total 100
drwxr-x--- 7 gitlab-runner users  4096 Aug  8 08:09 .
drwxr-x--- 4 gitlab-runner users  4096 Aug  7 10:18 ..
drwxr-x--- 8 gitlab-runner users  4096 Aug  7 10:18 .git
-rw-r----- 1 gitlab-runner users    68 Aug  7 10:18 .gitignore
-rw-r----- 1 gitlab-runner users   314 Aug  7 10:18 .gitlab-ci.yml
-rw-r----- 1 gitlab-runner users   261 Aug  7 10:18 .travis.yml
-rw-r----- 1 gitlab-runner users  1199 Aug  7 10:18 README.md
-rw-r----- 1 gitlab-runner users   725 Aug  7 11:33 build-gadget-snap.py
drwxr-x--- 2 gitlab-runner users  4096 Aug  7 10:18 gadget
-rw-r----- 1 gitlab-runner users 39908 Aug  7 10:18 icon.png
drwxr-x--- 2 gitlab-runner users  4096 Aug  7 10:18 legacy-bios
-rw-r----- 1 gitlab-runner users  4118 Aug  7 10:18 recovery.md
drwxr-x--- 2 gitlab-runner users  4096 Aug  7 10:18 snakeoil
drwxr-x--- 3 gitlab-runner users  4096 Aug  7 10:18 snap
-rw-r----- 1 gitlab-runner users  3091 Aug  7 11:33 snapcraft.yaml


gitlab-runner@clp-dev-gitlab-runner-snap-build-weu:~/test/salto-pc$ snapcraft --verbosity=debug
2024-08-08 09:16:01.175 Starting snapcraft, version 8.3.2
2024-08-08 09:16:01.175 Logging execution to '/home/gitlab-runner/.local/state/snapcraft/log/snapcraft-20240808-091601.173954.log'
2024-08-08 09:16:01.176 lifecycle command: 'pack', arguments: Namespace(destructive_mode=False, use_lxd=False, debug=False, enable_manifest=False, manifest_image_information=None, bind_ssh=False, build_for=None, http_proxy=None, https_proxy=None, ua_token=None, enable_experimental_ua_services=False, enable_experimental_plugins=False, enable_experimental_extensions=False, enable_developer_debug=False, enable_experimental_target_arch=False, target_arch=None, provider=None, directory=None, output=None)
2024-08-08 09:16:01.177 command: pack, arguments: Namespace(destructive_mode=False, use_lxd=False, debug=False, enable_manifest=False, manifest_image_information=None, bind_ssh=False, build_for=None, http_proxy=None, https_proxy=None, ua_token=None, enable_experimental_ua_services=False, enable_experimental_plugins=False, enable_experimental_extensions=False, enable_developer_debug=False, enable_experimental_target_arch=False, target_arch=None, provider=None, directory=None, output=None)
2024-08-08 09:16:01.193 CPU count (from process affinity): 2
2024-08-08 09:16:01.193 Invalid SNAPCRAFT_MAX_PARALLEL_BUILD_COUNT ''
2024-08-08 09:16:01.193 Running on amd64 for amd64
2024-08-08 09:16:01.194 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:01.195 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:01.195 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:01.195 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:01.196 Checking build provider availability
2024-08-08 09:16:01.204 Retrieved snap config: {}
2024-08-08 09:16:01.204 Using default provider 'lxd' on linux system.
2024-08-08 09:16:01.284 Executing on host: lxc --project default profile show local:default
2024-08-08 09:16:01.330 Using hostname 'snapcraft-salto-pc-on-amd64-for-amd64-1597995'
2024-08-08 09:16:01.330 Launching instance...
2024-08-08 09:16:01.330 Executing on host: lxc remote list --format=yaml
2024-08-08 09:16:01.371 Remote 'craft-com.ubuntu.cloud-buildd' already exists.
2024-08-08 09:16:01.372 Executing on host: lxc project list local: --format=yaml
2024-08-08 09:16:01.419 Set LXD instance name to 'snapcraft-salto-pc-on-amd64-for-amd64-1597995'
2024-08-08 09:16:01.420 Checking for instance 'snapcraft-salto-pc-on-amd64-for-amd64-1597995' in project 'snapcraft' in remote 'local'
2024-08-08 09:16:01.420 Executing on host: lxc --project snapcraft list local: --format=yaml
2024-08-08 09:16:01.573 Executing on host: lxc --project snapcraft config get local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 raw.idmap
2024-08-08 09:16:01.618 Executing on host: lxc --project snapcraft list local: --format=yaml
2024-08-08 09:16:01.721 Instance exists and is not running. Starting instance.
2024-08-08 09:16:01.722 Starting instance
2024-08-08 09:16:01.722 Executing on host: lxc --project snapcraft start local:snapcraft-salto-pc-on-amd64-for-amd64-1597995
2024-08-08 09:16:02.020 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical test -f /etc/craft-instance.conf
2024-08-08 09:16:02.194 Executing on host: lxc --project snapcraft file pull local:snapcraft-salto-pc-on-amd64-for-amd64-1597995/etc/craft-instance.conf /home/gitlab-runner/tmpjfmecbph.tmp-craft/tmp8ljwi695
2024-08-08 09:16:02.338 Instance has already been setup.
2024-08-08 09:16:02.339 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical cat /etc/os-release
2024-08-08 09:16:02.438 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical test -f /etc/craft-instance.conf
2024-08-08 09:16:02.557 Executing on host: lxc --project snapcraft file pull local:snapcraft-salto-pc-on-amd64-for-amd64-1597995/etc/craft-instance.conf /home/gitlab-runner/tmp56qfm78y.tmp-craft/tmpj64kceb1
2024-08-08 09:16:02.606 Instance is compatible with compatibility tag 'snapcraft-buildd-base-v7.1'
2024-08-08 09:16:02.606 No cache path set, not mounting cache directories.
2024-08-08 09:16:02.607 Waiting for environment to be ready...
2024-08-08 09:16:02.607 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical systemctl is-system-running
2024-08-08 09:16:02.736 systemctl is-system-running status: starting
2024-08-08 09:16:02.986 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical systemctl is-system-running
2024-08-08 09:16:03.125 systemctl is-system-running status: starting
2024-08-08 09:16:03.376 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical systemctl is-system-running
2024-08-08 09:16:03.493 systemctl is-system-running status: starting
2024-08-08 09:16:03.744 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical systemctl is-system-running
2024-08-08 09:16:03.851 systemctl is-system-running status: starting
2024-08-08 09:16:04.101 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical systemctl is-system-running
2024-08-08 09:16:04.199 systemctl is-system-running status: starting
2024-08-08 09:16:04.450 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical systemctl is-system-running
2024-08-08 09:16:04.522 Waiting for networking to be ready...
2024-08-08 09:16:04.523 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical getent hosts snapcraft.io
2024-08-08 09:16:04.621 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical snap unset system proxy.http
2024-08-08 09:16:04.836 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical snap unset system proxy.https
2024-08-08 09:16:05.058 Installing snap 'snapcraft' with channel=None and classic=True
2024-08-08 09:16:05.058 Installing snap 'snapcraft' from host (classic=True)
2024-08-08 09:16:05.063 Installing base snap 'core22' for 'snapcraft' from host
2024-08-08 09:16:05.063 Installing snap 'core22' from host (classic=False)
2024-08-08 09:16:05.066 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical test -f /etc/craft-instance.conf
2024-08-08 09:16:05.181 Executing on host: lxc --project snapcraft file pull local:snapcraft-salto-pc-on-amd64-for-amd64-1597995/etc/craft-instance.conf /home/gitlab-runner/tmpwrtxxv43.tmp-craft/tmp53xvy19y
2024-08-08 09:16:05.229 Revisions found: host='1439', target='1439'
2024-08-08 09:16:05.229 Skipping snap injection: target is already up-to-date with revision on host
2024-08-08 09:16:05.230 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical test -f /etc/craft-instance.conf
2024-08-08 09:16:05.345 Executing on host: lxc --project snapcraft file pull local:snapcraft-salto-pc-on-amd64-for-amd64-1597995/etc/craft-instance.conf /home/gitlab-runner/tmpx6d4td7r.tmp-craft/tmp_hsu_3oz
2024-08-08 09:16:05.391 Revisions found: host='12378', target='12378'
2024-08-08 09:16:05.392 Skipping snap injection: target is already up-to-date with revision on host
2024-08-08 09:16:05.392 Executing on host: lxc --project snapcraft config device show local:snapcraft-salto-pc-on-amd64-for-amd64-1597995
2024-08-08 09:16:05.434 Executing on host: lxc --project snapcraft config device add local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 disk-/root/project disk source=/home/gitlab-runner/test/salto-pc path=/root/project
2024-08-08 09:16:05.518 Executing on host: lxc --project snapcraft file push /tmp/tmps8m7nefr local:snapcraft-salto-pc-on-amd64-for-amd64-1597995/root/.bashrc --mode=644
2024-08-08 09:16:05.565 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical chown root:root /root/.bashrc
2024-08-08 09:16:05.648 Emitter: Pausing control of the terminal
2024-08-08 09:16:09.689 Starting snapcraft, version 8.3.2
2024-08-08 09:16:09.689 Logging execution to '/tmp/snapcraft.log'
2024-08-08 09:16:09.689 Configuring application...
2024-08-08 09:16:09.689 Preparing application...
2024-08-08 09:16:09.691 Build plan: platform=None, build_for=amd64
2024-08-08 09:16:09.691 Loading project file '/root/project/snapcraft.yaml'
2024-08-08 09:16:09.706 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:09.706 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:09.706 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:09.706 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:09.707 Processing grammar (on amd64 for amd64)
2024-08-08 09:16:09.707 Processing grammar for plugin: nil
2024-08-08 09:16:09.707 Processing grammar for stage-packages: ['dmidecode', 'uuid-runtime']
2024-08-08 09:16:09.707 Processing grammar for source: legacy-bios
2024-08-08 09:16:09.708 Processing grammar for plugin: make
2024-08-08 09:16:09.708 Processing grammar for override-build: if [ "amd64" != amd64 ]; then
    exit
fi
craftctl default
2024-08-08 09:16:09.708 Processing grammar for plugin: nil
2024-08-08 09:16:09.708 Processing grammar for build-packages: ['sbsigntool']
2024-08-08 09:16:09.708 Processing grammar for stage-packages: ['grub-efi-amd64-signed', 'shim-signed']
2024-08-08 09:16:09.708 Processing grammar for override-build: set -x

# Set some variables that depend on the architecture
grub_target=x86_64
grub_bin=grubx64.efi.signed
shim_bin=shimx64.efi.dualsigned
if [ "amd64" = arm64 ]; then
    grub_target=arm64
    grub_bin=grubaa64.efi.signed
    shim_bin=shimaa64.efi.dualsigned
fi

# Make sure we have signatures from the UC certificates
shim_path="$CRAFT_PART_INSTALL"/usr/lib/shim/$shim_bin
grub_path="$CRAFT_PART_INSTALL"/usr/lib/grub/"$grub_target"-efi-signed/$grub_bin
sbverify --list "$shim_path" | grep -E 'Canonical Ltd. Secure Boot Signing \(Ubuntu Core'
sbverify --list "$grub_path" | grep -E 'Canonical Ltd. Secure Boot Signing \(Ubuntu Core'

# Move shim/grub to the expected path
install -m 644 "$shim_path" "$CRAFT_PART_INSTALL"/shim.efi.signed
install -m 644 "$grub_path" "$CRAFT_PART_INSTALL"/${grub_bin%.signed}

# Remove all the bits we do not need, keeping changelogs and copyrights
# (using organize/prime is not possible due to different names per arch - x64/aa64)
find "$CRAFT_PART_INSTALL"/ -type f,l \
          -not -path "$SNAPCRAFT_PART_INSTALL"/shim.efi.signed \
          -not -path "$SNAPCRAFT_PART_INSTALL"/${grub_bin%.signed} \
          -not -path "$SNAPCRAFT_PART_INSTALL"/usr/share/doc/grub-efi-amd64-signed/'*' \
     -and -not -path "$SNAPCRAFT_PART_INSTALL"/'usr/share/doc/shim-signed/*' \
     -delete
find "$SNAPCRAFT_PART_INSTALL"/ -type d -empty -delete

# grub.conf lets snapd identify grub as the bootloader on boot
install -m 644 /dev/null "$CRAFT_PART_INSTALL"/grub.conf
2024-08-08 09:16:09.708 Processing grammar for plugin: nil
2024-08-08 09:16:09.709 Processing grammar for source: gadget
2024-08-08 09:16:09.709 Processing grammar for override-build: install -m 644 gadget-"amd64".yaml "/"/gadget.yaml
2024-08-08 09:16:10.439 Initialising lifecycle manager in /root
2024-08-08 09:16:10.440 Project vars: {'version': 'dirty', 'grade': 'stable'}
2024-08-08 09:16:10.441 Adopting part: None
2024-08-08 09:16:10.441 Using parallel build count of 2 from CPU count
2024-08-08 09:16:10.442 is_snap: True, SNAP_NAME set to snapcraft
2024-08-08 09:16:10.445 Unknown error: Could not find snap/snapcraft.yaml. Are you sure you are in the right directory?
2024-08-08 09:16:10.447 Traceback (most recent call last):
2024-08-08 09:16:10.447   File "/snap/snapcraft/12378/lib/python3.10/site-packages/craft_application/services/lifecycle.py", line 243, in run
2024-08-08 09:16:10.447     local_keys_path=self._get_local_keys_path(),
2024-08-08 09:16:10.447   File "/snap/snapcraft/12378/lib/python3.10/site-packages/snapcraft/services/lifecycle.py", line 192, in _get_local_keys_path
2024-08-08 09:16:10.447     snap_project = get_snap_project()
2024-08-08 09:16:10.448   File "/snap/snapcraft/12378/lib/python3.10/site-packages/snapcraft/parts/yaml_utils.py", line 232, in get_snap_project
2024-08-08 09:16:10.448     raise errors.ProjectMissing()
2024-08-08 09:16:10.448 snapcraft.errors.ProjectMissing: Could not find snap/snapcraft.yaml. Are you sure you are in the right directory?
2024-08-08 09:16:10.708 Emitter: Resuming control of the terminal
2024-08-08 09:16:10.709 Executing in container: lxc --project snapcraft exec local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical test -f /tmp/snapcraft.log
2024-08-08 09:16:10.824 Executing on host: lxc --project snapcraft file pull local:snapcraft-salto-pc-on-amd64-for-amd64-1597995/tmp/snapcraft.log /home/gitlab-runner/tmpbmscexd1.tmp-craft/tmpntk79t3o
2024-08-08 09:16:10.870 Logs retrieved from managed instance:
2024-08-08 09:16:10.870 :: 2024-08-08 09:16:09.689 Starting snapcraft, version 8.3.2
2024-08-08 09:16:10.870 :: 2024-08-08 09:16:09.689 Log verbosity level set to BRIEF
2024-08-08 09:16:10.870 :: 2024-08-08 09:16:09.689 Configuring application...
2024-08-08 09:16:10.870 :: 2024-08-08 09:16:09.689 Preparing application...
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.691 Build plan: platform=None, build_for=amd64
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.691 Loading project file '/root/project/snapcraft.yaml'
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.706 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.706 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.706 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.706 CRAFT_TARGET_ARCH is deprecated, use CRAFT_ARCH_BUILD_FOR
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.707 Processing grammar (on amd64 for amd64)
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.707 Processing grammar for plugin: nil
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.707 Processing grammar for stage-packages: ['dmidecode', 'uuid-runtime']
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.707 Processing grammar for source: legacy-bios
2024-08-08 09:16:10.871 :: 2024-08-08 09:16:09.708 Processing grammar for plugin: make
2024-08-08 09:16:10.872 :: 2024-08-08 09:16:09.708 Processing grammar for override-build: if [ "amd64" != amd64 ]; then
2024-08-08 09:16:10.872 ::     exit
2024-08-08 09:16:10.872 :: fi
2024-08-08 09:16:10.872 :: craftctl default
2024-08-08 09:16:10.872 :: 2024-08-08 09:16:09.708 Processing grammar for plugin: nil
2024-08-08 09:16:10.872 :: 2024-08-08 09:16:09.708 Processing grammar for build-packages: ['sbsigntool']
2024-08-08 09:16:10.872 :: 2024-08-08 09:16:09.708 Processing grammar for stage-packages: ['grub-efi-amd64-signed', 'shim-signed']
2024-08-08 09:16:10.872 :: 2024-08-08 09:16:09.708 Processing grammar for override-build: set -x
2024-08-08 09:16:10.872 ::
2024-08-08 09:16:10.872 :: # Set some variables that depend on the architecture
2024-08-08 09:16:10.873 :: grub_target=x86_64
2024-08-08 09:16:10.873 :: grub_bin=grubx64.efi.signed
2024-08-08 09:16:10.873 :: shim_bin=shimx64.efi.dualsigned
2024-08-08 09:16:10.873 :: if [ "amd64" = arm64 ]; then
2024-08-08 09:16:10.873 ::     grub_target=arm64
2024-08-08 09:16:10.873 ::     grub_bin=grubaa64.efi.signed
2024-08-08 09:16:10.873 ::     shim_bin=shimaa64.efi.dualsigned
2024-08-08 09:16:10.873 :: fi
2024-08-08 09:16:10.873 ::
2024-08-08 09:16:10.873 :: # Make sure we have signatures from the UC certificates
2024-08-08 09:16:10.873 :: shim_path="$CRAFT_PART_INSTALL"/usr/lib/shim/$shim_bin
2024-08-08 09:16:10.873 :: grub_path="$CRAFT_PART_INSTALL"/usr/lib/grub/"$grub_target"-efi-signed/$grub_bin
2024-08-08 09:16:10.874 :: sbverify --list "$shim_path" | grep -E 'Canonical Ltd. Secure Boot Signing \(Ubuntu Core'
2024-08-08 09:16:10.874 :: sbverify --list "$grub_path" | grep -E 'Canonical Ltd. Secure Boot Signing \(Ubuntu Core'
2024-08-08 09:16:10.874 ::
2024-08-08 09:16:10.874 :: # Move shim/grub to the expected path
2024-08-08 09:16:10.874 :: install -m 644 "$shim_path" "$CRAFT_PART_INSTALL"/shim.efi.signed
2024-08-08 09:16:10.874 :: install -m 644 "$grub_path" "$CRAFT_PART_INSTALL"/${grub_bin%.signed}
2024-08-08 09:16:10.874 ::
2024-08-08 09:16:10.874 :: # Remove all the bits we do not need, keeping changelogs and copyrights
2024-08-08 09:16:10.874 :: # (using organize/prime is not possible due to different names per arch - x64/aa64)
2024-08-08 09:16:10.874 :: find "$CRAFT_PART_INSTALL"/ -type f,l \
2024-08-08 09:16:10.874 ::           -not -path "$SNAPCRAFT_PART_INSTALL"/shim.efi.signed \
2024-08-08 09:16:10.874 ::           -not -path "$SNAPCRAFT_PART_INSTALL"/${grub_bin%.signed} \
2024-08-08 09:16:10.875 ::           -not -path "$SNAPCRAFT_PART_INSTALL"/usr/share/doc/grub-efi-amd64-signed/'*' \
2024-08-08 09:16:10.875 ::      -and -not -path "$SNAPCRAFT_PART_INSTALL"/'usr/share/doc/shim-signed/*' \
2024-08-08 09:16:10.875 ::      -delete
2024-08-08 09:16:10.875 :: find "$SNAPCRAFT_PART_INSTALL"/ -type d -empty -delete
2024-08-08 09:16:10.875 ::
2024-08-08 09:16:10.875 :: # grub.conf lets snapd identify grub as the bootloader on boot
2024-08-08 09:16:10.875 :: install -m 644 /dev/null "$CRAFT_PART_INSTALL"/grub.conf
2024-08-08 09:16:10.875 :: 2024-08-08 09:16:09.708 Processing grammar for plugin: nil
2024-08-08 09:16:10.875 :: 2024-08-08 09:16:09.709 Processing grammar for source: gadget
2024-08-08 09:16:10.875 :: 2024-08-08 09:16:09.709 Processing grammar for override-build: install -m 644 gadget-"amd64".yaml "/"/gadget.yaml
2024-08-08 09:16:10.875 :: 2024-08-08 09:16:10.439 Initialising lifecycle manager in /root
2024-08-08 09:16:10.875 :: 2024-08-08 09:16:10.440 Project vars: {'version': 'dirty', 'grade': 'stable'}
2024-08-08 09:16:10.875 :: 2024-08-08 09:16:10.441 Adopting part: None
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.441 Using parallel build count of 2 from CPU count
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.442 is_snap: True, SNAP_NAME set to snapcraft
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.445 Unknown error: Could not find snap/snapcraft.yaml. Are you sure you are in the right directory?
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.447 Traceback (most recent call last):
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.447   File "/snap/snapcraft/12378/lib/python3.10/site-packages/craft_application/services/lifecycle.py", line 243, in run
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.447     local_keys_path=self._get_local_keys_path(),
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.447   File "/snap/snapcraft/12378/lib/python3.10/site-packages/snapcraft/services/lifecycle.py", line 192, in _get_local_keys_path
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.447     snap_project = get_snap_project()
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.448   File "/snap/snapcraft/12378/lib/python3.10/site-packages/snapcraft/parts/yaml_utils.py", line 232, in get_snap_project
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.448     raise errors.ProjectMissing()
2024-08-08 09:16:10.876 :: 2024-08-08 09:16:10.448 snapcraft.errors.ProjectMissing: Could not find snap/snapcraft.yaml. Are you sure you are in the right directory?
2024-08-08 09:16:10.877 Executing on host: lxc --project snapcraft config device show local:snapcraft-salto-pc-on-amd64-for-amd64-1597995
2024-08-08 09:16:10.919 Executing on host: lxc --project snapcraft config device remove local:snapcraft-salto-pc-on-amd64-for-amd64-1597995 disk-/root/project
2024-08-08 09:16:11.002 Executing on host: lxc --project snapcraft stop local:snapcraft-salto-pc-on-amd64-for-amd64-1597995
2024-08-08 09:16:15.135 Failed to execute pack in instance.
2024-08-08 09:16:15.137 Traceback (most recent call last):
2024-08-08 09:16:15.137   File "/snap/snapcraft/12378/lib/python3.10/site-packages/snapcraft/application.py", line 351, in main
2024-08-08 09:16:15.137     return app.run()
2024-08-08 09:16:15.138   File "/snap/snapcraft/12378/lib/python3.10/site-packages/snapcraft/application.py", line 179, in run
2024-08-08 09:16:15.138     return_code = super().run()
2024-08-08 09:16:15.138   File "/snap/snapcraft/12378/lib/python3.10/site-packages/craft_application/application.py", line 492, in run
2024-08-08 09:16:15.138     dispatcher = self._get_dispatcher()
2024-08-08 09:16:15.138   File "/snap/snapcraft/12378/lib/python3.10/site-packages/snapcraft/application.py", line 298, in _get_dispatcher
2024-08-08 09:16:15.138     raise errors.ClassicFallback()
2024-08-08 09:16:15.138 snapcraft.errors.ClassicFallback
2024-08-08 09:16:15.138
2024-08-08 09:16:15.138 During handling of the above exception, another exception occurred:
2024-08-08 09:16:15.139 Traceback (most recent call last):
2024-08-08 09:16:15.139   File "/snap/snapcraft/12378/lib/python3.10/site-packages/snapcraft/parts/lifecycle.py", line 542, in _run_in_provider
2024-08-08 09:16:15.139     instance.execute_run(cmd, check=True, cwd=output_dir)
2024-08-08 09:16:15.139   File "/snap/snapcraft/12378/lib/python3.10/site-packages/craft_providers/lxd/lxd_instance.py", line 293, in execute_run
2024-08-08 09:16:15.139     return self.lxc.exec(
2024-08-08 09:16:15.139   File "/snap/snapcraft/12378/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 387, in exec
2024-08-08 09:16:15.139     return runner(final_cmd, timeout=timeout, check=check, **kwargs)
2024-08-08 09:16:15.139   File "/snap/snapcraft/12378/usr/lib/python3.10/subprocess.py", line 526, in run
2024-08-08 09:16:15.139     raise CalledProcessError(retcode, process.args,
2024-08-08 09:16:15.139 subprocess.CalledProcessError: Command '['lxc', '--project', 'snapcraft', 'exec', 'local:snapcraft-salto-pc-on-amd64-for-amd64-1597995', '--cwd', '/root/project', '--', 'env', 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'CRAFT_MANAGED_MODE=1', 'DEBIAN_FRONTEND=noninteractive', 'DEBCONF_NONINTERACTIVE_SEEN=true', 'DEBIAN_PRIORITY=critical', 'snapcraft', 'pack', '--verbosity=debug', '--build-for', 'amd64']' returned non-zero exit status 1.
2024-08-08 09:16:15.140 Recommended resolution: Run the same command again with --debug to shell into the environment if you wish to introspect this failure.
2024-08-08 09:16:15.140 Full execution log: '/home/gitlab-runner/.local/state/snapcraft/log/snapcraft-20240808-091601.173954.log'

I have successfully managed to run it with sudo and if i gave 777 permission to CWD. But this is still open question for me, since i can build it on my host without sudo (both my host and runner VM is in group of lxd ad sudo).

Hi @aliihsan

I’ve been building gadgets using gitlab runners, I’m not sure if this helps but I’ve kept my snapcraft.yaml at the root of the folder for that gadget snap, but also make this step in the process:

cp gadget/gadget-amd64.yaml gadget.yaml

I noticed that snapcraft running locally would do this step for me, but not on a gitlab CI runner. I cannot remember the details of the error I got when I did not do this step, but something in my mind tells me the error message was something to the effect that you see.

Hope this helps!