Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ run configuration environment variables not appearing in System.getenv

I have an IntelliJ project. I have an Application class with a main function and a chunk of AWS code, part of which looks for the AWS credentials in the environment.

Following these instructions, I set those credentials as environment variables in the run configuration: https://www.jetbrains.com/help/idea/run-debug-configuration-application.html enter image description here

Previously, I tried using the EnvFile plugin (which is still active), and pointed it at an appropriate env file, also containing the AWS credentials (as well as other env vars).

I am using this code snippet to print out all the environment variables:

StringBuilder sb = new StringBuilder();
Map<String, String> env = System.getenv();
for (String key : env.keySet()) {
  sb.append(key + ": " + env.get(key)  + "\n");
}
System.out.println(sb.toString());

I then run that configuration from the Run menu.

My global environment variables are printed (as expected) but none from the configuration, or from the EnvFile.

Where should I look next to resolve this issue?

like image 782
Narfanator Avatar asked Oct 19 '25 01:10

Narfanator


1 Answers

I had this issue today on my M1 Macbook with IntelliJ IDEA 2022.2 (Ultimate Edition).

The fix for me, in this instance, was to upgrade the Gradle wrapper version in the project. Specifically, from 6.2.1 to 7.5.1.

like image 62
Chris Sainty Avatar answered Oct 21 '25 14:10

Chris Sainty



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!