How to get access to .so in system?

Hi.
I’m developing a Electron-based app. For pack into snap package I use electron-builder. All works fine.
But in last two releases I noticed that my snap package does not work. After run, the app crashes with next error:

/snap/figma-linux/x1/figma-linux: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory

This error came after that I put libfreetype2.so into project, in root dir, to keep specific version of the library. It’s need for normal work of the app, where is version of the library is different.

Output of:

snap run --strace figma-linux 2>&1 | tail -50
open("/snap/figma-linux/x1/usr/lib/x86_64-linux-gnu/pulseaudio/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/snap/figma-linux/x1/usr/lib/x86_64-linux-gnu/mesa-egl/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/snap/figma-linux/x1/lib/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/snap/figma-linux/x1/usr/lib/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/snap/figma-linux/x1/lib/x86_64-linux-gnu/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("tls/x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("tls/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/snap/figma-linux/x1/usr/lib/x86_64-linux-gnu/dri/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd1bdab1000
open("/lib/x86_64-linux-gnu/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/x86_64", 0x7fff53895280) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls", 0x7fff53895280) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/x86_64", 0x7fff53895280) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=4281, ...}) = 0
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/x86_64", 0x7fff53895280) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls", 0x7fff53895280) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/x86_64", 0x7fff53895280) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=2789, ...}) = 0
open("/lib/tls/x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls/x86_64", 0x7fff53895280) = -1 ENOENT (No such file or directory)
open("/lib/tls/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 EN
OENT (No such file or directory)
stat("/lib/tls", 0x7fff53895280)        = -1 ENOENT (No such file or directory)
open("/lib/x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64", 0x7fff53895280)     = -1 ENOENT (No such file or directory)
open("/lib/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib", {st_mode=S_IFDIR|0755, st_size=406, ...}) = 0
open("/usr/lib/tls/x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/x86_64", 0x7fff53895280) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls", 0x7fff53895280)    = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7fff53895280) = -1 ENOENT (No such file or directory)
open("/usr/lib/libpng16.so.16", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=747, ...}) = 0
writev(2, [{iov_base="/snap/figma-linux/x1/figma-linux", iov_len=32}, {iov_base=": ", iov_len=2}, {iov_base="error while loading shared libra"..., iov_len=36}, {iov_base=": ", iov_len=2}, {iov_base="libpng16.so.16", iov_len=14}, {iov_base=": ", iov_len=2}, {iov_base="cannot open shared object file", iov_len=30}, {iov_base=": ", iov_len=2}, {iov_base="No such file or directory", iov_len=25}, {iov_base="\n", iov_len=1}], 10/snap/figma-linux/x1/figma-linux: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
) = 146
exit_group(127)                         = ?
+++ exited with 127 +++
error: exit status 127

The libpng lib exists in a system:

find /lib /usr -name "libpng16.so*"
/usr/lib/x86_64-linux-gnu/libpng16.so.16
/usr/lib/x86_64-linux-gnu/libpng16.so
/usr/lib/x86_64-linux-gnu/libpng16.so.16.36.0
/usr/lib/libpng16.so.16
/usr/lib/i386-linux-gnu/libpng16.so.16
/usr/lib/i386-linux-gnu/libpng16.so
/usr/lib/i386-linux-gnu/libpng16.so.16.36.0

Is the package cannot find the lib in system?
How to fix that?

Strict confined snaps run in what is called a private “mount namespace”. What this means is that they see a different view of the file system to other processes on the system. In particular, they will see a different root file system: namely that of their base snap (generally core or core18).

This might seem inconvenient (“why can’t it find libpng16.so.16? It’s right there!”), but it has the benefit that your app is running the same set of libraries no matter what distro it is installed on. If the library you are after is not provided by the base snap you’re using, then you’ll need to bundle it with your own snap. The stage-packages stanza in your snapcraft.yaml is the usual way to handle this. If electron-builder is creating the snapcraft.yaml, then it might have an equivalent.

2 Likes

Thank you for answer.
But now, I cannot build the package.

Got error
Skipping pull desktop-gtk3 (already ran)
'app' has dependencies that need to be staged: desktop-gtk3
Skipping pull desktop-gtk3 (already ran)
Building desktop-gtk3 
+ snapcraftctl build
make FLAVOR=gtk3 -j8
gcc -Wall -O2 -o bindtextdomain.so -fPIC -shared ./../src/bindtextdomain.c -ldl
make FLAVOR=gtk3 install DESTDIR=/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/snap/parts/desktop-gtk3/install
install -D -m755 desktop-launch "/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/snap/parts/desktop-gtk3/install"/bin/desktop-launch
install -D -m644 flavor-select "/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/snap/parts/desktop-gtk3/install"/
install -D -m644 bindtextdomain.so "/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/snap/parts/desktop-gtk3/install"/lib/bindtextdomain.so
+ export XDG_DATA_DIRS=/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/snap/parts/desktop-gtk3/install/usr/share
+ update-mime-database /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/snap/parts/desktop-gtk3/install/usr/share/mime
+ [ -f /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/snap/parts/desktop-gtk3/install/usr/share/icons/Adwaita//index.theme ]
+ 
+ gtk-update-icon-cache-3.0 -q /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/snap/parts/desktop-gtk3/install/usr/share/icons/Adwaita/
/bin/sh: 38: gtk-update-icon-cache-3.0: not found
+ which gtk-update-icon-cache-3.0
Failed to run 'override-build': Exit code was 127.
my snapcraft.yaml
name: figma-linux
version: 0.5.1
summary: figma-linux
description: Unofficial desktop application for linux
confinement: strict
grade: stable
base: core18
architectures:
  - amd64

apps:
  figma-linux:
    command: exec $SNAP/bin/desktop-launch "$SNAP/app/figma-linux"
    plugs:
      - desktop
      - desktop-legacy
      - home
      - x11
      - unity7
      - browser-support
      - network
      - gsettings
      - pulseaudio
      - opengl
    environment:
      TMPDIR: $XDG_RUNTIME_DIR
      PATH: '$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH'
      LD_LIBRARY_PATH: '$SNAP_LIBRARY_PATH:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu/pulseaudio:$SNAP/usr/lib/x86_64-linux-gnu/mesa-egl:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu'
    adapter: none
parts:
  app:
    plugin: nil
    stage-packages:
      - libasound2
      - libgconf2-4
      - libnotify4
      - libnspr4
      - libnss3
      - libpcre3
      - libpulse0
      - libxss1
      - libxtst6
      - libappindicator1
      - libsecret-1-0
      - libpng16-16
    after:
      - desktop-gtk3
  desktop-gtk3:
    override-build: |-
      set -x
      snapcraftctl build
      export XDG_DATA_DIRS=$SNAPCRAFT_PART_INSTALL/usr/share
      update-mime-database $SNAPCRAFT_PART_INSTALL/usr/share/mime

      for dir in $SNAPCRAFT_PART_INSTALL/usr/share/icons/*/; do
        if [ -f $dir/index.theme ]; then
          if which gtk-update-icon-cache-3.0 &> /dev/null; then
            gtk-update-icon-cache-3.0 -q $dir
          elif which gtk-update-icon-cache &> /dev/null; then
            gtk-update-icon-cache -q $dir
          fi
        fi
      done
    stage:
      - '-./usr/share/fonts/**'
icon: ../resources/icon/icon.png

1 Like

update-icon-cache comes with libgtk-3-bin, you want this in the build-packages of your desktop-gtk3 part (and i guess a lot other dependencies too, check the upstream repo for this desktop launcher)

1 Like

Hi. I added libgtk-3-bin in build-packages. But now I got new error :pensive: :disappointed:

log
The package libgconf2-4 has unmet dependencies: 
  ⨯ exit status 2
github.com/develar/app-builder/pkg/util.ExecuteWithInheritedStdOutAndStdErr
	/Volumes/data/Documents/app-builder/pkg/util/util.go:59
github.com/develar/app-builder/pkg/package-format/snap.buildWithoutDockerAndWithoutTemplate
	/Volumes/data/Documents/app-builder/pkg/package-format/snap/snap.go:320
github.com/develar/app-builder/pkg/package-format/snap.Snap
	/Volumes/data/Documents/app-builder/pkg/package-format/snap/snap.go:232
github.com/develar/app-builder/pkg/package-format/snap.ConfigureCommand.func1
	/Volumes/data/Documents/app-builder/pkg/package-format/snap/snap.go:103
github.com/alecthomas/kingpin.(*actionMixin).applyActions
	/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/actions.go:28
github.com/alecthomas/kingpin.(*Application).applyActions
	/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:557
github.com/alecthomas/kingpin.(*Application).execute
	/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:390
github.com/alecthomas/kingpin.(*Application).Parse
	/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:222
main.main
	/Volumes/data/Documents/app-builder/main.go:80
runtime.main
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/proc.go:200
runtime.goexit
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/asm_amd64.s:1337

Error: /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-bin/linux/x64/app-builder exited with code 1
    at ChildProcess.childProcess.once.code (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/builder-util/src/util.ts:244:14)
    at Object.onceWrapper (events.js:277:13)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
From previous event:
    at SnapTarget.build (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/targets/snap.ts:148:44)
    at Function.buildAsyncTargets (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/platformPackager.ts:140:36)
    at LinuxPackager.packageInDistributableFormat (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/platformPackager.ts:119:24)
    at /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/platformPackager.ts:114:10
    at Generator.next (<anonymous>)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
From previous event:
    at LinuxPackager.pack (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/platformPackager.ts:111:95)
    at /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/packager.ts:430:24
    at Generator.next (<anonymous>)
    at xfs.stat (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/fs-extra-p/node_modules/fs-extra/lib/mkdirs/mkdirs.js:56:16)
    at /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqWrap.oncomplete (fs.js:155:5)
From previous event:
    at Packager.doBuild (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/packager.ts:396:24)
    at /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/packager.ts:366:57
    at Generator.next (<anonymous>)
    at /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/graceful-fs/graceful-fs.js:99:16
    at /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:141:20)
From previous event:
    at Packager._build (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/packager.ts:335:133)
    at /media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/packager.ts:331:23
    at Generator.next (<anonymous>)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
From previous event:
    at Packager.build (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/packager.ts:288:14)
    at build (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/app-builder-lib/src/index.ts:59:28)
    at build (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/electron-builder/src/builder.ts:228:10)
    at then (/media/ruut/ssd/Projects/MyProjects/JS/figma-linux/node_modules/electron-builder/src/cli/cli.ts:49:19)

the actual error is most likely above this …

1 Like

There’re no any errors above

please post the whole log to paste.ubuntu.com or a similar service. While we understand that you think the bits you have omitted are irrelevant to the problem you are encountering, it is difficult for us to verify without the full output.

If you are running an Ubuntu derivative then you may apt install pastebinit and then run snapcraft | pastebinit and copy the URL it shows after the build has stopped to a post in this topic. For other systems you may try snapcraft > snapcraft.log and copy the contents of snapcraft.log in your current directory to the pastebin of your choice, again stating the URL to your paste here in another post.

1 Like

I resolved this problem. I just put libpng.so, libm.so and libz beside the app in snap package.