toolbox icon indicating copy to clipboard operation
toolbox copied to clipboard

set environment variables for run command

Open bam80 opened this issue 5 years ago • 6 comments

Didn't find a way to do so. Should we add it?

bam80 avatar Nov 06 '20 00:11 bam80

What's the use-case?

The idea behind the run command was to enable people to write their own desktop files for graphical applications installed inside Toolbox containers. Usually desktop files don't set ad hoc environment variables.

debarshiray avatar Dec 18 '20 23:12 debarshiray

In my case, I need to pass proper QT_QPA_PLATFORM to run as X11 or Wayland client. I worked out this Exec line for my .desktop file on host but need yet to make sure it works:

Exec=env QT_QPA_PLATFORM=xcb toolbox -c kde.f33 run ~/Charm/Charm/charmtimetracker

bam80 avatar Dec 18 '20 23:12 bam80

Ok, yes, sounds like we should it. :)

debarshiray avatar Dec 21 '20 10:12 debarshiray

In addition to single environment variables, would it be possible to support an environment file parameter with more than one variable please? Similar to what "podman exec --env-file" does. My use case is restic backups, which require a bunch of variables to be passed to define the repository, etc.

jorgeml avatar Dec 21 '20 11:12 jorgeml

I used a workaround to pass "Gnome-Builder external command" env variables:

toolbox run bash -c "SRCDIR=$SRCDIR flatpak-remote-builder build"

bellegarde-c avatar Aug 13 '22 17:08 bellegarde-c

More specific toolbox containers would also benefit from those envs, since some devtools prefix commands with various environment variables to execute tests, compilation, linting, debugging session, etc.

For example, to start the NodeJS debugger, Webstorm (Jetbrains’ IDE) uses the following envs (and probably more):

NODE_OPTIONS: '--require /home/***/.local/share/JetBrains/Toolbox/apps/webstorm/plugins/javascript-debugger/debugConnector.js',
JB_IDE_PORT: '43961',
JB_INTERPRETER: '/usr/bin/node',
JB_IDE_HOST: '127.0.0.1',
_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE: 'test',

When node is actually a toolbox run --container node node "$@", those envs are not available to the node runtime and the Debugger is not started.

bmenant avatar Dec 15 '23 18:12 bmenant