Install hook failed while install snap

Hello, i encountered this error when i trying install my snap that built myself with this tutorial Packaging a Qt5 application (Bomber) as an IoT GUI.

there are error-out

ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap$ snapcraft
Generated snap metadata
Created snap package pec-gui_1.0_amd64.snap
ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap$ sudo snap install pec-gui_1.0_amd64.snap --dangerous
[sudo] password for ubuntu: 
error: cannot perform the following tasks:
Run install hook of "pec-gui" snap if present (run hook "install": cannot snap-exec: no such file or directory)

This is my snapcraft.yaml . the PEC-GUI is my binary execute.

name: pec-gui  # you probably want to 'snapcraft register <name>'
version: '1.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: IoT for PEC-GUI # 79 char long summary
description: IoT for PEC-GUI
confinement: strict
compression: lzo
grade: stable
base: core22

# This is one of four snippets that relate to providing the userspace graphics needed by your application.
# You can treat this as "magic" so long as you don't need to make changes.
# On the Mir website there's a lot more detail on [the graphics-core22 Snap interface](https://mir-server.io/docs/the-graphics-core22-snap-interface) and it's use.
plugs:
  graphics-core22:
    interface: content
    target: $SNAP/graphics
    default-provider: mesa-core22

environment:
  # Other, generally useful environment settings...
  # XDG config
  XDG_CACHE_HOME:  $SNAP_USER_COMMON/.cache
  XDG_CONFIG_HOME: $SNAP_USER_DATA/.config
  XDG_CONFIG_DIRS: $SNAP/etc/xdg
  XDG_DATA_DIRS:   $SNAP/usr/local/share:$SNAP/usr/share
  # XKB config
  XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb

# The `layout` ensures that files can be found by applications where they are expected by the toolkit or application.
layout:
  /usr/share/libdrm:
    bind: $SNAP/graphics/libdrm
  /usr/share/drirc.d:
    symlink: $SNAP/graphics/drirc.d
  # Other, generally useful paths
  /usr/share/fonts:
    bind: $SNAP/usr/share/fonts
  /usr/share/icons:
    bind: $SNAP/usr/share/icons
  /usr/share/sounds:
    bind: $SNAP/usr/share/sounds
  /etc/fonts:
    bind: $SNAP/etc/fonts
  /usr/share/alsa:
    bind: $SNAP/usr/share/alsa
  /usr/bin:
    bind: $SNAP/usr/bin

lint:
  ignore:
    - library
    - classic

parts:
  qt-app:
    plugin: dump
    source: ./qt5
    source-type: local
    override-prime: |
      craftctl default

      mkdir -p $SNAPCRAFT_PART_INSTALL/lib/qt5
    organize:
      lib/: $SNAPCRAFT_PART_INSTALL/lib/qt5/lib/
      plugins/: $SNAPCRAFT_PART_INSTALL/lib/qt5/plugins/
      translations/: $SNAPCRAFT_PART_INSTALL/lib/qt5/translations/
    stage-packages:
      - qtwayland5
  
  PEC-GUI:
    plugin: dump
    source: snap/local
    source-type: local
    override-prime: |
      craftctl default

      mkdir -p $CRAFT_PRIME/usr/bin
    organize:
      PEC-GUI: bin/
      style/*: bin/style/
    after:
      - qt-app
    prime:
      - bin/PEC-GUI

  # Because Bomber won't run without a session dbus, and this isn't available to daemons on core
  # (there is no "session") we need to include a dbus session in the snap.
  # The `source: dbus` contains a script and configuration file for running `dbus-run-session`.
  dbus:
    plugin: dump
    source: dbus
    override-build: |
      # replace the SNAP_NAME placeholder with our actual project name
      sed --in-place "s/SNAP_NAME/$CRAFT_PROJECT_NAME/" $CRAFT_PART_BUILD/etc/dbus-1/session.conf
      craftctl default

  # Some utility scripts for setting up the Wayland environment
  setup:
    plugin: dump
    source: wayland-launch
    override-build: |
      # The plugs needed to run Wayland. (wayland-launch checks them, setup.sh connects them)
      # You may add further plugs here if you want these options
      PLUGS="opengl wayland graphics-core22 network-bind"
      sed --in-place "s/%PLUGS%/$PLUGS/g" $CRAFT_PART_BUILD/bin/wayland-launch
      sed --in-place "s/%PLUGS%/$PLUGS/g" $CRAFT_PART_BUILD/bin/setup.sh
      craftctl default
    stage-packages:
      - inotify-tools

  graphics-core22:
    after:
      - dbus
      - setup
      - PEC-GUI
      - qt-app
    source: https://github.com/canonical/gpu-snap.git 
    plugin: dump
    override-prime: |
      craftctl default
      ${CRAFT_PART_SRC}/bin/graphics-core22-cleanup mesa-core22 nvidia-core22
      cd "$CRAFT_PRIME/usr/share/"
      rm -rf bug drirc.d glvnd libdrm lintian man \
             bash-completion dbus-1 help kconf_update kservices5 libinput locale openal pkgconfig \
             applications doc kf5 kservicetypes5 libthai metainfo perl qlogging-categories5 thumbnailers xml \
             apport config.kcfg doc-base GConf gnupg info knotifications5 kxmlgui5 libwacom themes sounds
    prime:
      - bin/graphics-core22-wrapper
      
apps:
  bins:
    command-chain: &_command-chain
      - bin/graphics-core22-wrapper
      - bin/wayland-launch
      - bin/dbus-launch
    command: &_command bin/PEC-GUI
    plugs: &_plugs
      - opengl
      - wayland
      - audio-playback
    environment: &_environment
      # These environment variables are typically needed by Qt applications to ensue the snapped version of
      # Qt components are found and used
      QT_QPA_PLATFORM: wayland
      QT_PLUGIN_PATH: ${SNAPCRAFT_PART_INSTALL}/lib/qt5/plugins/
      QT_QPA_PLATFORM_PLUGIN_PATH: ${SNAPCRAFT_PART_INSTALL}/lib/qt5/plugins/platforms/
      QML2_IMPORT_PATH: ${SNAPCRAFT_PART_INSTALL}/lib/qt5/qml
      QT_DIR: ${SNAPCRAFT_PART_INSTALL}/lib/qt5
      LD_LIBRARY_PATH: ${SNAPCRAFT_PART_INSTALL}/lib/qt5:$LD_LIBRARY_PATH

  daemon:
    daemon: simple
    restart-delay: 3s
    restart-condition: always
    command-chain: *_command-chain
    command: *_command
    plugs: *_plugs
    environment: *_environment

architectures:
  - build-on: amd64
  - build-on: armhf
  - build-on: arm64

My folder structure like it

.
└── snap
    ├── hooks
    │   ├── configure
    │   ├── install
    │   └── post-refresh
    └── snapcraft.yaml

this is the install file from git https://github.com/canonical/iot-example-graphical-snap/tree/22/Qt5-bomber

#!/bin/sh set -x

if [ “$(snapctl get daemon)” = “” ] then if ! snapctl model > /dev/null || [ “$( snapctl model | awk ‘/^classic:/ { print $2 }’ )” = “true” ] then snapctl set daemon=false else snapctl set daemon=true fi fi

Any there are suggestions for me?

unsquashfs your snap and check if the install hook is actually executable, snapcraft 8.x has a bug (though i thought only in other areas) where it drops executable bits from certain files, check if you are hit by this …

Hi, thanks for your reply! I did what your suggestions,it’s like the install hook is executable.

ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap$ unsquashfs pec-gui_1.0_amd64.snap
Parallel unsquashfs: Using 2 processors
765 inodes (2114 blocks) to write

[=============================================================-] 2114/2114 100%

created 673 files
created 89 directories
created 92 symlinks
created 0 devices
created 0 fifos
created 0 sockets
ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap$ cd squashfs-root
ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap/squashfs-root$ ls
'$SNAPCRAFT_PART_INSTALL'   bin   etc   meta   snap   usr
ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap/squashfs-root$ cd snap
ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap/squashfs-root/snap$ ls
hooks
ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap/squashfs-root/snap$ cd hooks
ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap/squashfs-root/snap/hooks$ ls 
configure  install  post-refresh
ubuntu@ubuntu-virtual-machine:~/iot-example-graphical-snap/squashfs-root/snap/hooks$ ls -l
total 12
-rwxr-xr-x 1 ubuntu ubuntu 442 12月 16 16:14 configure
-rwxrwxr-x 1 ubuntu ubuntu 299 12月 16 16:14 install
-rwxrwxr-x 1 ubuntu ubuntu 299 12月 16 16:14 post-refresh

And my snapcraft version 8.5.0 and running ubuntu22.04 on VM. Any other suggestions from you?