Snap which chromium

I have written a script to launch chromium. In the process of debugging the script I realized I couldn’t actually figure out how “snap” chromium eventually starts. Eventually I got the actual executable path from ps, but it’s quite a path to get from /snap/bin/chromium -> /usr/bin/snap -> /snap/chromium/current/usr/lib/chromium-browser/chrome -> /snap/chromium/current/usr/lib/chromium-browser/chrome.launcher (what I really want). Something like snap which chromium that reports the final pathname of the executable/script would be helpful. If it’s there and I just didn’t read enough documentation, please point me in the right direction. Thanks.

You don’t actually want that path - if you execute that, it will lack confinement, environment, basically it will just circumvent what the snap is.

Use /usr/bin/snap run chromium instead.

If I’m troubleshooting something, in my case one script calling another, I want to confirm that I’m calling what I expect and with the right args. If I have multiple versions of a snap installed, I think that’s even more important. Chromium might be an anomaly since the snap itself has it’s own launcher script, chromium.launcher.

Snaps defining their own launcher script is fairly common practice, there’s nothing very special about chromium in that regard (but the launcher script is an implementation detail that you shouldn’t rely on).

Let me reiterate what @Saviq said: you need to run snaps through snapd, otherwise confinement won’t work as expected, and things are likely to break in funny ways.

Re multiple versions: if you’re referring to parallel installs, then each instance lives under a unique instance name, so there’s no ambiguity. Otherwise there’s only one version of any given snap actually installed and enabled, so again, no ambiguity.

We’re talking past each other, but I’ll give it one more go. snap which might be a useful suggestion, but now that I understand more, perhaps unnecessary.

In my bash script, I execute chromium which I assume “runs through snapd” indirectly. I don’t break the abstraction(s) afaik and therefore enjoy all the snap/snapd protections. Which I admit to not fully appreciating. If I want to know what’s happening under the covers, I can:

$ snap list --all chromium; echo; chromium --version # see what's installed locally
Name      Version        Rev   Tracking       Publisher   Notes
chromium  81.0.4044.129  1135  latest/stable  canonical✓  disabled
chromium  81.0.4044.138  1143  latest/stable  canonical✓  -

Chromium 81.0.4044.138 snap

$ echo 'env|grep SNAP; exit' | snap run --shell chromium  # see Rev 1143's SNAP env
SNAP_USER_DATA=/home/mcarifio/snap/chromium/1143
SNAP_REVISION=1143
SNAP_ARCH=amd64
SNAP_INSTANCE_KEY=
SNAP_USER_COMMON=/home/mcarifio/snap/chromium/common
SNAP=/snap/chromium/1143
SNAP_COMMON=/var/snap/chromium/common
SNAP_NAME=chromium
SNAP_INSTANCE_NAME=chromium
SNAP_DATA=/var/snap/chromium/1143
SNAP_COOKIE=bP2DtTVSVqdwBgBTXsLdBHhyld0v8CQPp87fqVX0L4n5
SNAP_REEXEC=
SNAP_CONTEXT=bP2DtTVSVqdwBgBTXsLdBHhyld0v8CQPp87fqVX0L4n5
SNAP_VERSION=81.0.4044.138
SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void

$ echo 'grep command $SNAP/snap/snapcraft.yaml; exit' | snap run --shell chromium # see what gets invoked
    command: bin/desktop-launch "$SNAP/bin/chromium.launcher"
    command: usr/lib/chromium-browser/chromedriver

$ echo 'type desktop-launch; exit' | snap run --shell chromium # ... and how
desktop-launch is /snap/chromium/1143/bin/desktop-launch

This gets me where I wanted to go a few days ago and I learned a little bit more snapcraft (haha) along the way. I can also conclude that chromium in bash eventually runs /snap/chromium/1143/bin/desktop-launch /snap/chromium/1143/bin/chromium.launcher (in a specialized environment). Reviewing those scripts helped me improve my own.

FWIW, you can just do this instead:

snap run --shell chromium -c 'env|grep SNAP'

What is it you are trying to do with your scripts?

Ty for -c.

I want to start chromium with separate profiles from the command line, which seems to involve the flags --profile-directory and --user-data-dir if the profiles are in a non-standard place. The interaction between those two switches are themselves confusing, so I wanted to rule out that chromium.launcher wasn’t “helping” by overriding my values. It’s working now, but my script might be unnecessary after all this. I’ll know soon enough with some more experimentation. Obviating my own “wrapper” script would be good thing by the way. One less thing to debug.