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

Env vars are lost in bazel run configurations #6163

Closed
tpasternak opened this issue Feb 27, 2024 · 6 comments · Fixed by #6164
Closed

Env vars are lost in bazel run configurations #6163

tpasternak opened this issue Feb 27, 2024 · 6 comments · Fixed by #6164
Assignees
Labels
awaiting-maintainer Awaiting review from Bazel team on issues Release Blocker issue is blocking the plugin release type: bug

Comments

@tpasternak
Copy link
Collaborator

Description of the bug:

  1. Run any code printing environment variables using bazel's run configuration
  2. Run a shell script using shell run configuration and print the same variables

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which Intellij IDE are you using? Please provide the specific version.

No response

What programming languages and tools are you using? Please provide specific versions.

No response

What Bazel plugin version are you using?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@tpasternak tpasternak added type: bug awaiting-maintainer Awaiting review from Bazel team on issues labels Feb 27, 2024
@mai93 mai93 added the Release Blocker issue is blocking the plugin release label Feb 27, 2024
@mai93
Copy link
Collaborator

mai93 commented Feb 27, 2024

Based on @tpasternak analysis this is expected to be due to #5885. @blorente can you please take a look?

@tpasternak
Copy link
Collaborator Author

So it seems like for some users the plugin is unusable now - all the tests fail

@blorente
Copy link
Collaborator

I'll take a look first time tomorrow.

tpasternak added a commit to tpasternak/bazel-intellij that referenced this issue Feb 27, 2024
…MacOS

Use CONSOLE ParentEnvironmentType instead of SYSTEM

CONSOLE is the default value initialized in GeneralCommandLineso it was used before. Now, if we want to inherit the system envs we use SYSTEM,
so in both cases it differs from what was there before. This PR just brings the old behavior in case a user wants to inherit enviroment from the system.

https://github.com/JetBrains/intellij-community/blob/9838665ba816fc8ce06e4071aa5a906a35fbb22e/platform/platform-util-io/src/com/intellij/execution/configurations/GeneralCommandLine.java#L85C1-L86C1

fixes bazelbuild#6163
@tpasternak
Copy link
Collaborator Author

@blorente thanks, I think I've found the root cause but I'm not sure if this matches the overall idea

tpasternak added a commit that referenced this issue Feb 27, 2024
…MacOS (#6164)

Use CONSOLE ParentEnvironmentType instead of SYSTEM

CONSOLE is the default value initialized in GeneralCommandLineso it was used before. Now, if we want to inherit the system envs we use SYSTEM,
so in both cases it differs from what was there before. This PR just brings the old behavior in case a user wants to inherit enviroment from the system.

https://github.com/JetBrains/intellij-community/blob/9838665ba816fc8ce06e4071aa5a906a35fbb22e/platform/platform-util-io/src/com/intellij/execution/configurations/GeneralCommandLine.java#L85C1-L86C1

fixes #6163
mai93 pushed a commit that referenced this issue Feb 27, 2024
…MacOS (#6164)

Use CONSOLE ParentEnvironmentType instead of SYSTEM

CONSOLE is the default value initialized in GeneralCommandLineso it was used before. Now, if we want to inherit the system envs we use SYSTEM,
so in both cases it differs from what was there before. This PR just brings the old behavior in case a user wants to inherit enviroment from the system.

https://github.com/JetBrains/intellij-community/blob/9838665ba816fc8ce06e4071aa5a906a35fbb22e/platform/platform-util-io/src/com/intellij/execution/configurations/GeneralCommandLine.java#L85C1-L86C1

fixes #6163
mai93 pushed a commit that referenced this issue Feb 27, 2024
…MacOS (#6164)

Use CONSOLE ParentEnvironmentType instead of SYSTEM

CONSOLE is the default value initialized in GeneralCommandLineso it was used before. Now, if we want to inherit the system envs we use SYSTEM,
so in both cases it differs from what was there before. This PR just brings the old behavior in case a user wants to inherit enviroment from the system.

https://github.com/JetBrains/intellij-community/blob/9838665ba816fc8ce06e4071aa5a906a35fbb22e/platform/platform-util-io/src/com/intellij/execution/configurations/GeneralCommandLine.java#L85C1-L86C1

fixes #6163
@blorente
Copy link
Collaborator

Hello! I'm trying to repro this issue to add some automated tests, but I'm not seeing any difference between CONSOLE and SYSTEM.
I have the following setup:

  • BUILD .bazel
sh_binary(
    name = "test_env_vars_bin",
    srcs = ["test_env_vars.sh"],
)
  • test_env_vars.sh
#!/usr/bin/env bash
set -euo pipefail

echo "USER: $USER"
echo "PATH: $PATH"
echo "HOME: $HOME"
echo "GOROOT: $GOROOT"

And both SYSTEM and CONSOLE print the same thing as running the script with a "Run Shell" run configuration.
Could you give an example of an env var that you'd expect to be there that is not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-maintainer Awaiting review from Bazel team on issues Release Blocker issue is blocking the plugin release type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants