Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra_env_vars for system_binary #20373

Open
ubmarco opened this issue Jan 6, 2024 · 0 comments · May be fixed by #20374
Open

extra_env_vars for system_binary #20373

ubmarco opened this issue Jan 6, 2024 · 0 comments · May be fixed by #20374

Comments

@ubmarco
Copy link

ubmarco commented Jan 6, 2024

Is your feature request related to a problem? Please describe.
I want to use drawio as a system_binary. It crashes with SIGSEGV and other errors if the following environment variables are not given: DISPLAY, HOME, DBUS_SESSION_BUS_ADDRESS.
When pants runs the fingerprinting step, it invokes the binary with a cleared environment. There is currently no way to specify which env vars to keep for the fingerprinting step.

Describe the solution you'd like
Add the parameter extra_env_vars to system_binary, just like it exists for adhoc_tool or shell_command.

Describe alternatives you've considered
Workaround the issue by creating a wrapper shell script that replies to only the fingerprinting using a special args value and forwards all other options and parameters to the target system binary.

Additional context
The fingerprinting error:

ValueError: Could not find a binary with name `drawio`.
The following paths were searched: /bin, /opt/drawio, /opt/homebrew/bin, /usr/bin, /usr/local/bin, /usr/sbin.

Btw, the error message is quite misleading as the binary can be found, just the fingerprinting fails.
This was already reported in #19013.

The generated __run.sh currently looks like this:

#!/usr/bin/env bash
# This command line should execute the same process as pants did internally.
cd /tmp/pants-sandbox-lpxUQZ
env -i  /opt/drawio/drawio --version

Executing __run.sh manually reveals the error:

$ env -i  /opt/drawio/drawio --version
[152836:0106/210646.416373:ERROR:ozone_platform_x11.cc(240)] Missing X server or $DISPLAY
[152836:0106/210646.416407:ERROR:env.cc(257)] The platform failed to initialize.  Exiting.
[1]    152836 segmentation fault (core dumped)  env -i /opt/drawio/drawio --version
@ubmarco ubmarco linked a pull request Jan 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant