Git error while building snap

I’m trying to build a snap and I’m having the following error:

$ snapcraft --debug     
Launching a VM.
                                                                                                                                      
   snap "core18" has no updates available
Skipping pull pgweb (already ran)
Skipping build pgweb (already ran)
Skipping stage pgweb (already ran)
Skipping prime pgweb (already ran)
Determining the version from the project repo (version: git).
fatal: not a git repository (or any parent up to mount point /root)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I understand that snapcraft is trying to get the version from git, but it’s not being able to find the git repository. I understand that but I don’t know how to act on it. Here is my snapcraft.yaml:

name: pgweb-kemelzaidan
base: core18
version: git
summary: Cross-platform client for PostgreSQL databases
description: |
  Pgweb is a cross-platform web-based database browser for PostgreSQL,
  written in Go.

grade: devel
confinement: devmode

parts:
  pgweb:
    source-type: git
    source: https://github.com/sosedoff/pgweb.git
    plugin: go
    go-importpath: github.com/sosedoff/pgweb
    build-packages:
      - gcc

apps:
  pgweb:
    command: pgweb

version: git really only works if your snapcraft.yaml is in the source tree you’re building. So either fork https://github.com/sosedoff/pgweb.git and add the snapcraft.yaml to it and build it there as one option. The other option is to omit version: git and instead use adopt-info pgweb and then override-build: | which does snapcraftctl build and snapcraftctl set-version $(git describe --tags) or similar to generate a version string.

A bit like https://github.com/snapcrafters/obs-studio/blob/master/snap/snapcraft.yaml#L133

1 Like

Thanks! It worked! :slight_smile:

I believe this information should be in the docs though. I tried looking for snapcraftctl function at the documentation and couldn’t find much too… Can you help me?

1 Like

I agree! In fact I’m on the train to London right now for a snapcraft documentation hacking day. So this information about what’s missing here is very useful, thanks! We’ll try and resolve this.

1 Like