canonical / snapcraft

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

".snapcraft.yaml" not picked up as a project file #5083

Open SuperAlpaca27 opened 1 week ago

SuperAlpaca27 commented 1 week ago

Bug Description

When trying to use .snapcraft.yaml as the project file (with, for example https://github.com/maxiberta/htop-snap), snapcraft gives the error:

❯ snapcraft      
Project file 'snapcraft.yaml' not found in '/home/superalpaca/canonical/htop-snap'.                                                                                                                                 
Recommended resolution: Ensure the project file exists.                                                                                                                                                             
Full execution log: '/home/superalpaca/.local/state/snapcraft/log/snapcraft-20241001-130647.933900.log'

I've only tried this on snapcraft 8.4.1 with a core24 snap, so not sure if this applies to others versions/bases as well.

To Reproduce

Prerequisite is snapcraft 8.4.1 installed on the system

git clone https://github.com/maxiberta/htop-snap
cd htop-snap
mv snap/snapcraft.yaml .snapcraft.yaml
snapcraft

Environment

On Ubuntu 24.04.1 LTS, using snapcraft 8.4.1 and using LXD for the build I think

snapcraft.yaml

name: htop
base: core24
adopt-info: htop
summary: Interactive processes viewer
description: |
  htop is an ncurses-based process viewer similar to top, but it
  allows one to scroll the list vertically and horizontally to see
  all processes and their full command lines. Tasks related to
  processes (killing, renicing) can be done without entering their PIDs.

  Once installed, this snap can _optionally_ be connected to some extra plugs:

     sudo snap connect htop:mount-observe
     sudo snap connect htop:network-control  # DELAYACCT support

  Main website: https://htop.dev/

icon: htop.png
grade: devel
confinement: strict
license: GPL-2.0
compression: lzo

apps:
  htop:
    command-chain: [bin/locales-launch]
    command: usr/local/bin/htop
    desktop: usr/local/share/applications/htop.desktop
    environment:
      TERMINFO_DIRS: $SNAP/lib/terminfo:$SNAP/usr/share/terminfo
    plugs:
      - network
      - hardware-observe
      - mount-observe
      - network-control
      - process-control
      - system-observe

parts:
  htop:
    plugin: autotools
    source: https://github.com/htop-dev/htop
    source-type: git
    source-branch: main
    autotools-configure-parameters:
      - --enable-capabilities
      - --enable-delayacct
      - --enable-linux-affinity
      - --enable-openvz
      - --enable-sensors
      - --enable-unicode
      - --enable-vserver
    override-build: |
      craftctl set version=$(git describe --tags --long)
      craftctl default
    build-packages:
      - libcap-dev
      - libgcc-s1
      - libncurses-dev
      - libnl-3-dev
      - libnl-genl-3-dev
      - libsensors-dev
      - pkg-config
    stage-packages:
      - kitty-terminfo
      - libcap2
      - libncursesw6
      - libsensors5
      - libtinfo6
      - libsystemd0
      - ncurses-base
      - ncurses-term
      - lsof
      - strace

  # Stage snap for fixing the Glibc locales
  # https://forum.snapcraft.io/t/the-locales-launch-stage-snap/10296
  locales-launch:
    source: https://github.com/Lin-Buo-Ren/locales-launch.git
    source-tag: v1.0.0
    plugin: dump
    stage-packages:
    # For localedef(1)
    - libc-bin
    # For locale data used by localedef(1)
    - locales
    # All pre-generated locale data
    # DISABLED: Lots of duplicate data will be included in snap when this is staged, unless the target machine has no resource to generate them in runtime otherwise not using it
    #   Lack of compiled locales breaks gettext based localisation - snapcraft - snapcraft.io
    #   https://forum.snapcraft.io/t/lack-of-compiled-locales-breaks-gettext-based-localisation/3758
    #- locales-all
    stage:
      - bin/locales-launch
      - etc/locale.alias
      - usr/bin/localedef
      - usr/share/doc/locales
      - usr/share/i18n
      - usr/share/locale

Relevant log output

2024-10-01 13:06:47.934 Starting snapcraft, version 8.4.1
2024-10-01 13:06:47.934 Log verbosity level set to BRIEF
2024-10-01 13:06:47.934 Preparing application...
2024-10-01 13:06:47.934 Configuring application...
2024-10-01 13:06:47.935 Setting up ConfigService
2024-10-01 13:06:47.956 Build plan: platform=None, build_for=None
2024-10-01 13:06:47.956 Project file 'snapcraft.yaml' not found in '/home/superalpaca/canonical/htop-snap'.
2024-10-01 13:06:47.956 Detailed information: The project file could not be found.
2024-10-01 13:06:47.959 Traceback (most recent call last):
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/lib/python3.10/site-packages/snapcraft/application.py", line 173, in _resolve_project_path
2024-10-01 13:06:47.959     return super()._resolve_project_path(project_dir / "snap")
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/lib/python3.10/site-packages/craft_application/application.py", line 252, in _resolve_project_path
2024-10-01 13:06:47.959     return (project_dir / f"{self.app.name}.yaml").resolve(strict=True)
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/usr/lib/python3.10/pathlib.py", line 1077, in resolve
2024-10-01 13:06:47.959     s = self._accessor.realpath(self, strict=strict)
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/bin/../usr/lib/python3.10/posixpath.py", line 396, in realpath
2024-10-01 13:06:47.959     path, ok = _joinrealpath(filename[:0], filename, strict, {})
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/bin/../usr/lib/python3.10/posixpath.py", line 431, in _joinrealpath
2024-10-01 13:06:47.959     st = os.lstat(newpath)
2024-10-01 13:06:47.959 FileNotFoundError: [Errno 2] No such file or directory: '/home/superalpaca/canonical/htop-snap/snap/snapcraft.yaml'
2024-10-01 13:06:47.959 
2024-10-01 13:06:47.959 During handling of the above exception, another exception occurred:
2024-10-01 13:06:47.959 Traceback (most recent call last):
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/lib/python3.10/site-packages/snapcraft/application.py", line 176, in _resolve_project_path
2024-10-01 13:06:47.959     return super()._resolve_project_path(project_dir)
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/lib/python3.10/site-packages/craft_application/application.py", line 252, in _resolve_project_path
2024-10-01 13:06:47.959     return (project_dir / f"{self.app.name}.yaml").resolve(strict=True)
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/usr/lib/python3.10/pathlib.py", line 1077, in resolve
2024-10-01 13:06:47.959     s = self._accessor.realpath(self, strict=strict)
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/bin/../usr/lib/python3.10/posixpath.py", line 396, in realpath
2024-10-01 13:06:47.959     path, ok = _joinrealpath(filename[:0], filename, strict, {})
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/bin/../usr/lib/python3.10/posixpath.py", line 431, in _joinrealpath
2024-10-01 13:06:47.959     st = os.lstat(newpath)
2024-10-01 13:06:47.959 FileNotFoundError: [Errno 2] No such file or directory: '/home/superalpaca/canonical/htop-snap/snapcraft.yaml'
2024-10-01 13:06:47.959 
2024-10-01 13:06:47.959 During handling of the above exception, another exception occurred:
2024-10-01 13:06:47.959 Traceback (most recent call last):
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/lib/python3.10/site-packages/craft_application/application.py", line 273, in get_project
2024-10-01 13:06:47.959     project_path = self._resolve_project_path(self.project_dir)
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/lib/python3.10/site-packages/snapcraft/application.py", line 178, in _resolve_project_path
2024-10-01 13:06:47.959     return super()._resolve_project_path(project_dir / "build-aux" / "snap")
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/lib/python3.10/site-packages/craft_application/application.py", line 252, in _resolve_project_path
2024-10-01 13:06:47.959     return (project_dir / f"{self.app.name}.yaml").resolve(strict=True)
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/usr/lib/python3.10/pathlib.py", line 1077, in resolve
2024-10-01 13:06:47.959     s = self._accessor.realpath(self, strict=strict)
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/bin/../usr/lib/python3.10/posixpath.py", line 396, in realpath
2024-10-01 13:06:47.959     path, ok = _joinrealpath(filename[:0], filename, strict, {})
2024-10-01 13:06:47.959   File "/snap/snapcraft/12607/bin/../usr/lib/python3.10/posixpath.py", line 431, in _joinrealpath
2024-10-01 13:06:47.959     st = os.lstat(newpath)
2024-10-01 13:06:47.959 FileNotFoundError: [Errno 2] No such file or directory: '/home/superalpaca/canonical/htop-snap/build-aux'
2024-10-01 13:06:47.959 Recommended resolution: Ensure the project file exists.
2024-10-01 13:06:47.959 Full execution log: '/home/superalpaca/.local/state/snapcraft/log/snapcraft-20241001-130647.933900.log'

Additional context

No response

syncronize-issues-to-jira[bot] commented 1 week ago

Thank you for reporting us your feedback!

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

This message was autogenerated

mr-cal commented 1 week ago

Thanks for the bug report. I can confirm this is a regression with how snapcraft and craft-application load project files.

We will need some refactoring in craft-application to support this.