Resolve 'package contains external symlinks' error when trying to snap

My snap is building successfully but I haven’t found a work around for this issue below:

Error:package contains external symlinks: usr/lib/jvm/java-8-openjdk-armhf/jre/lib/security/cacerts

I’m very unsure as to what I should do to fix this.

This is describing a real problem with your snap which is that the usr/lib/jvm/java-8-openjdk-armhf/jre/lib/security/cacerts file is pointing somewhere outside your snap, which is not guaranteed to exist. In this particular case, it will prevent ssl encrypted connections like https to not work within your snap.

This is described here (with workaround): https://bugs.launchpad.net/ubuntu/+source/snapcraft/+bug/1599281

I think if you install openjdk-8-jre-headless and ca-certificates-java on your system, then when you run snapcraft, snapcraft will pull them in. I’ve also had success using this in the snapcraft.yaml when using ‘snapcraft cleanbuild’:

    build-packages:
    - ca-certificates
    - ca-certificates-java
    - openjdk-8-jre-headless
    stage-packages:
    - openjdk-8-jre-headless

UPDATE: added ‘openjdk-8-jre-headless’ to build-packages too since ca-certificates-java will pull in openjdk-9-jre-headless in cleanbuild.

3 Likes

I’m getting this error for core20 again. The same packages are present for building - is there an underlying change that is causing this? Do I need to add something more to my snapcraft.yaml?

YAML is here.