[SOLVED] Unable to access x11-utils in snap

I’m creating an Electron app that calls out to xprops to gather information from the WM.

I’ve included x11-utils in stage-packages. I’ve tried to add -usr/bin/xprop to app.stage, and I’ve tried to add a bind / symlink in layouts from /usr/bin/xprop to $SNAP/usr/bin/xprop.

Nothing works - the Node.js code in Electron is saying “spawn xprop ENOENT”, which means xprop isn’t found. I’ve looked in /usr/bin at runtime and it’s just not there.

My snapcraft.yaml is here: https://pastebin.com/27MJyE7j

Any help would be appreciated!


I’m new here so I hope I’m not saying anything stupid but:

  1. How do you “call out to xprops” in your Electron app?
  2. How do you “look in /usr/bin at runtime”?
  3. I don’t see a layout in your snapcraft.yaml file:
            bind-file: $SNAP/usr/bin/xprops

Thanks Dimitri.

  1. We use child_process.execFile. I’ve tried with exec() as well

  2. child_process.exec("ls -l /usr/bin/x*", ...). With bind-file, it outputs:

    lrwxrwxrwx 1 root root 7 Apr 9 11:46 /usr/bin/x86_64 -> setarch
    -rwxr-xr-x 1 root root 71896 Nov 5 2017 /usr/bin/xargs
    -rwxr-xr-x 1 root root 38 Mar 10 22:46 /usr/bin/xdg-open
    -rwxr-xr-x 1 root root 886 Mar 10 22:46 /usr/bin/xdg-settings
    -rwxr-xr-x 1 root root 0 Apr 9 11:49 /usr/bin/xprop
    -rwxr-xr-x 1 root root 18552 Jun 6 2019 /usr/bin/xxd

With symlinks, I get instead:

lrwxrwxrwx 1 root root    30 Apr  9 11:54 /usr/bin/xprop -> /snap/tandem/x15/usr/bin/xprop
  1. I’ve tried bind, symlink, and bind-file in the layouts section, they all do something but none of them seem to work.

-rwxr-xr-x 1 root root 0 Apr 9 11:49 /usr/bin/xprop

Isn’t the size of the file 0?

-rwxr-xr-x 1 root root 38 Mar 10 22:46 /usr/bin/xdg-open

The size of xdg-open is suspiciously small too.

Yeah, I don’t think it exists in $SNAP/usr/bin - seems like maybe the stage-packages process isn’t working properly?

Yes, this seems wrong. The xprops file should be visible as /snap/tandem/current/usr/bin/xprops. What if you run ls /snap/tandem/current/usr/bin/xprops from the command line?

Hmm… /snap/tandem/current/usr/bin doesn’t exist, either from within the app, or on my file system.

Whatever directory the snap is installed into. On which system do you install the snap?

I’m using Ubuntu 18 for development and testing. The app works fine outside of the snap, and via other distribution methods (e.g. deb, AppImage).

Should /snap/tandem/current/usr/bin exist? only usr/lib exists.

You’re trying to run /usr/bin/xprop. It must be made available in the snap, typically like the following:

        bind-file: $SNAP/usr/bin/xprop

In the above case xprop is expected in $SNAP/usr/bin/xprop/snap/tandem/current/usr/bin/xprop. However xprop could be stored elsewehere for example in $SNAP/lib/alternative/location/xprop/snap/tandem/current/lib/alternative/location/xprop:

        bind-file: $SNAP/lib/alternative/location/xprop

Now you have added xprop by including x11-utils in stage-packages, so I would expect xprop to have been installed as $SNAP/usr/bin/xprop.

The problem is that you add some stuff with stage-packages and then remove most of it under stage.

For example you remove all of $SNAP/usr/bin:

      - -usr/bin

My guess is that you have misunderstood the the meaning of the initial - (dash). The syntax of stage is similar to the syntax of filesets. I suggest you remove stage completely - and put it back later on if really needed.

Amazing! I was able to get it working after that. Had no clue that the - would strip that folder. Thank you Dimitri