When building a snap and constructing a part, you commonly need to specify build and staging dependencies.
These dependencies are listed in snapcraft.yaml within a part definition, with
build-packages used to list packages required for the part to build, and
stage-packages used to list packages required by the part to run.
The following is a typical example of a part’s build- and stage- sections for a command tool line thats interacts with git:
build-packages: - pkg-config - libreadline-dev - libncurses5-dev stage-packages: - git
Dependencies are listed as package names for the snap’s build environment.
It’s also feasible to have a build environment built on Fedora for example, using Fedora packages, or those of your own host environment.
The packages you need are likely to be identical to those you need to either build your project (
build-packages) or install your project (
stage-packages). You’ll often find them listed in a project’s README.md, or alongside any build instructions.
Debugging missing packages
Working out your project’s dependencies can be an iterative process, much like compiling a third-party package:
- when you have a workable framework snapcraft.yaml for your snap, run
snapcraft --debuguntil you hit an error
- If that error is a build dependency, use the debug interactive shell to work out which package is required
- add the package to your snapcraft.yaml and type snapcraft within the build environment to see if you have the same error