Are user-defined environment variable supported or not?

There are numerous references to environment variables in the docs and this forum including:

These all seem to imply that snap restricts the environment variable passed (at build or run time) to a set predetermined by snap and the application packager (is that the right term?). Nowhere is there any hint about what control an end-user has over any environment variables an application sees.

Now, I’ve been struggling to get the Chromium snap to work under Selenium via chromedriver on a remote desktop between snap-based bogosity (variously over /home and $HOME, and the need to control $XAUTHORITY) as well as Chromium bogosity over GPUs etc. needing to be overridden using $QT_X11_NO_MITSHM. Today, on a whim, and against the tide of hints mentioned above and my limited understanding of the purpose of snap, I tried setting these and to my amazement, it all worked. Now, in hindsight, if I had read

carefully enough, I would have realised this earlier. Is it worth adding some explicit statement somewhere to to explain:

  • User-defined environment variable ARE propagated to the application
  • Does this work if the application packager sets the same variable in the metadata adapter/environment?

Thanks, Shaheed

while user environment is fully supported, note that applications often use the desktop-launch helpers (or any other wrappers).

they might override some of the env variables you set … so i’d carefully test with each single one :wink:

1 Like