Craftctl fails to fetch from local repo branch other than `master`

I’m trying to build snapcraft.yaml « snap - rtmpvideostreamer - [no description] on snapcraft.io and get https://launchpadlibrarian.net/782503644/buildlog_snap_ubuntu_noble_amd64_rtmp-video-streamer-stable_BUILDING.txt.gz

Some internals:

  1. repository contains code in master branch (for edge channel builds)
  2. it has stable branch pointing to the same commit as master atm (for stable channel builds)
  3. repository has some other branches with different snap dirs (I want to build multiple snap packages from the same sources)

and if snapcraft.yaml points to master branch - it builds fine, but if to stable I see in logs following:

RuntimeError: Failed to pull source: command ['/snap/snapcraft/13860/libexec/snapcraft/craft.git', 'clone', '--recursive', '--branch', 's', 'file:///build/rtmp-video-streamer', '/build/rtmp-video-streamer/parts/streamer/src'] exited with code 128.

The same code builds without any issue locally. Is it a bug, or I just miss something?

Thanks in advance for any hints.

nvm, found solution. It looks like it’s some bug in git version used for core24 builds. To get it working it was required to force create local tracking branch in override-pull before craftctl default

1 Like

Glad you found a solution, but if the snapcraft.yaml is located in the project that contains the source code, you can remove source-type and source-branch and the git override.

You could simplify your snapcraft.yaml from:

    plugin: cmake
    source-type: git
    source: .
    source-branch: stable
    override-pull: |
        git -C $CRAFT_PROJECT_DIR branch --track stable origin/stable
        craftctl default
        craftctl set version="$(git describe --always)"

to:

    plugin: cmake
    source: .
    override-pull: |
        craftctl default
        craftctl set version="$(git describe --always)"

source-type and source-branch aren’t useful when you have a local source with source: ., since it doesn’t need to be fetched from a remote location.

1 Like

@mr_cal thank you for your hint. It will be useful in some of my other snaps. But it will not work in that specific case. There snap directory resides in one branch (without any other sources in it) and sources in other (without snap directory). So it’s required to point to branch where sources are explicitly, even if it’s the same (and current) repository …