"No such file or directory" error with override-build

Hello,

I am trying to build the dotrun snap using this snapcraft.yaml:

But I get an error:

Building semwraplib 
gcc: error: /root/parts/semwraplib/build/lib.c: No such file or directory

And it seems that the entire build folder is empty.

Could you tell me what is wrong?

Thank you!

You need to snapcraftctl build first if you want $SNAPCRAFT_PART_BUILD to have any files in it.

Hi Sergio!

Thank you for the response, I don’t have the binary snapcraftctl in my system, do I need to install something?

Thank you.

@sergiusens SNAPCRAFT_PART_BUILD was just us experimenting to try to debug it. The core issue is that when I build the snap it works fine, but it fails for @jkfran.

The relevant block is this:

  semwraplib:
    plugin: dump
    source: src
    override-build: |
      mkdir -p $SNAPCRAFT_PART_INSTALL/lib
      gcc -g -O0 -Wall -Wstrict-prototypes -fPIC -shared lib.c -o $SNAPCRAFT_PART_INSTALL/lib/semwraplib.so -ldl
    build-packages:
      - build-essential 

(https://github.com/canonical-web-and-design/dotrun/blob/721c156cadf32b40d682e162c855e31f9dc38313/snap/snapcraft.yaml#L24-L31)

And it references src/lib.c, which exists in the codebase here, but when Fran builds it, it doesn’t seem to exist.

I don’t understand why Fran’s snapcraft should be behaving differently from mine. We’re both on version 3.10.2, and we don’t think there are any relevant config settings set.

1 Like

Can you run snapcraft --debug, that should drop you in a shell, then ls parts/semwraplib/build and verify that the file is there?

Hi Sergio,

Is empty:

➜  dotrun git:(master) snapcraft --debug
Launching a VM.
snap "snapd" has no updates available                                           
Skipping pull dotrun-module (already ran)
Skipping pull node (already ran)
Skipping pull semwraplib (already ran)
Skipping pull yarn (already ran)
Skipping build dotrun-module (already ran)
Skipping build node (already ran)
Building semwraplib 
gcc: error: lib.c: No such file or directory
Failed to run 'override-build': Exit code was 1.
snapcraft-dotrun # ls parts/semwraplib/build
snapcraft-dotrun # 

your files will be in $SNAPCRAFT_PART_SOURCE. They are not copied to build/ because you are not calling snapcraftctl build.

note that snapcraftctl isnt any binary on your system but internally used by snapcraft during the build process so you will not just easily find it … just call snapcraftctl build right above your mkdir line and you should be good to go.

Ah makes sense, thanks. sorry. Filed:

Out of interest, why would it have worked for me?

If you had previously run snapcraft without the override-build: then the directories would have been populated from that run.

Yeah but it also succeeded in CI, that has no previous builds:

snapcraftctl build calls the plugin logic. File migration is done at a higher level, so this is not the root cause.

Does this work is you snapcraft --use-lxd?
Does you git status show anything strange (like removed files)?

Hello Sergio,

I am in the branch master of dotrun, I modified the snapcraft.yaml to remove the snapcraftctl build line that we now have and using snapcraft --use-lxd works perfectly well.

With git status, the only change that I see in the repo is the modification that I made to remove snapcraftctl build.