First attempt with snap, very confused - error: cannot pack "/build/aiyy/prime": snap is unusable due to missing files)

name: aiyy
base: core22
version: '0.1'
summary: CLI assistant for technical information
description: |
  Get technical information on the command line with ease using AIY. Simply type in your question as the prompt and 
  receive a beautifully formatted and helpful response. This snap also has options for resetting the API key and 
  toggling warnings. 
  - build-on: [amd64]
grade: devel
confinement: devmode

    command: bin/aiy

    plugin: python
    source: ../.
      - wheel
      - pip
      - openai==0.26.4
      - python-dotenv==0.21.1
      - rich==13.3.1

I’ve tried, python-requriements, I tried using setuptools with a setupscript, I’ve been at it 12 hours and trying different approaches. After my 50th failed build, I decided to come and ask for help. I just can not find enough examples and am fundamentally misunderstanding something.

I set up the bin/aiy as a script that runs the entrypoint as such “exec python3 “$SNAP/” “$@””

I am not sure if I’m getting close, or am going down another incorrect path. When I tried to use requirements file, I didn’t know if it it was looking in directory of yaml or from base path of snap, so I tried both …/requirements.txt and requirements.txt and neither seemed to work correctly.

Code I’m trying to build:

Cannot pack snap file: Command '['snap', 'pack', '--filename', 'aiyy_0.1_amd64.snap', '--compression', 'xz', PosixPath('/build/aiyy/prime'), PosixPath('/build/aiyy')]' returned non-zero exit status 1. (container.go:215: in snap "aiyy": path "bin/aiy" does not exist
error: cannot pack "/build/aiyy/prime": snap is unusable due to missing files)
Full execution log: '/root/.cache/snapcraft/log/snapcraft-20230203-123218.062509.log'
Build failed
Traceback (most recent call last):
 File "/usr/lib/python3/dist-packages/lpbuildd/target/", line 204, in run
 File "/usr/lib/python3/dist-packages/lpbuildd/target/", line 188, in build
   self.run_build_command(["snapcraft"], cwd=output_path, env=env)
 File "/usr/lib/python3/dist-packages/lpbuildd/target/", line 51, in run_build_command
   return, cwd=cwd, env=full_env, **kwargs)
 File "/usr/lib/python3/dist-packages/lpbuildd/target/", line 571, in run
   subprocess.check_call(cmd, **kwargs)
 File "/usr/lib/python3.8/", line 364, in check_call
   raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['lxc', 'exec', 'lp-jammy-amd64', '--env', 'LANG=C.UTF-8', '--env', 'SHELL=/bin/sh', '--env', 'http_proxy=', '--env', 'https_proxy=', '--env', 'GIT_PROXY_COMMAND=/usr/local/bin/lpbuildd-git-proxy', '--env', 'SNAPPY_STORE_NO_CDN=1', '--env', 'SNAPCRAFT_BUILD_INFO=1', '--env', 'SNAPCRAFT_IMAGE_INFO={"build-request-id": "lp-77219697", "build-request-timestamp": "2023-02-03T12:30:00Z", "build_url": ""}', '--env', 'SNAPCRAFT_BUILD_ENVIRONMENT=host', '--env', 'SNAPCRAFT_BUILD_FOR=amd64', '--', '/bin/sh', '-c', 'cd /build/aiyy && linux64 snapcraft']' returned non-zero exit status 1.

Any help would be appreciated… Resources I’ve been looking into: [removed links because I’m new user] and others… any assistance would be appreciated

I guess the source should be the link of the project.

source-type: git
source-tag: 1.0

This is using the github integration, and is linked directly to the github repository… it seems that might be redundant? (I’m giving it a try)

Try it once, tho I didn’t know about this github integration thing

From Build snaps from GitHub repositories Auto-build and publish software for any Linux system or device from your GitHub repos.

This is why I thought the snapcraft file would be self-referential, since the linkage to the repository is defined this way. However, with these changes it was still the same error message :frowning: I don’t know if these are public or not

I’m going to try /build/aiy maybe that was my issue… that my snapcraft is in /snap/snapcraft so it could have been looking for /snap/snapcraft/build/aiy

Some progress… now ‘builds’, but fails to release

Creating snap package...
9361cc09d93cb858af46377bca530ddd0346de5f5349e48fd483f64fc067ccfb85dbb4c8bc5e60b2fe03688e3a71c52e74a93957e4229066a065b556986d6176  aiyy_0.1_amd64.snap
Revoking proxy token...
RUN: /usr/share/launchpad-buildd/bin/in-target scan-for-processes --backend=lxd --series=jammy --arch=amd64 SNAPBUILD-2011625

you should have received a mail with the feedback from the review-tools run on the server that states why it failed to release (most likely some interface that needs special approval, or some symlink that points outside of the sandbox or some such) … if you have no such mail you can log in to the old page and go to the revision of your upload, scroll down to the “automated review” section and find the reason there …

It couldn’t find /bin/aiy :frowning: “…/bin/aiy does not exist lint-snap-v2_command (aiyy)”

Oddly, if I put /bin/aiy or bin/aiy, it fails and doesn’t give this does not exist error.

I think maybe this is part of the problem. Maybe half of the search results are classic confinement and I’ve been using the wrong examples. How do I know if I’m using classic confinement? Is that confinement: classic? I’m using devmode, so that shouldn’t be the case. So the command needs to be in $SNAP/bin. So, I should just use comand: aiy. Testing this

The command to run inside the snap when <app-name> is invoked. Type: string The command can be in either a snap runtime’s command path, $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin, or an executable path relative to $SNAP. If daemon is set, this will be the command to run the service. Only a snap with classic confinement can use a relative path because PATH isn’t modified by a wrapper in classic confinement. See Classic confinement for more details.

That didn’t help. I’m stuck :frowning: If anyone has any ideas I’m open to trying anything. For now I’m putting snap on the backburner

The source: entry change pointing to the git repository is necessary, and additionally it seems that your entry point bin/aiy is not being installed. Something like this should take care of installing it:

    plugin: python
    override-build: |
      craftctl default
      install -m755 $CRAFT_PART_SRC/bin/aiy $CRAFT_PART_INSTALL/bin/

What I do for situations like this is add somthing like bash to stage-packages then change the command to bin/bash That lets the snap build and release. Once released, you can install it and inspect your file system /snap/<yourapp>/current/ and search for where your aiy binary is. Maybe instead of bin/aiy it’s getting installed to usr/bin/aiy or something like that.