EnvFile icon indicating copy to clipboard operation
EnvFile copied to clipboard

The environment variables do not apply to the Java application on IntelliJ IDEA 2025.02.

Open dbaloyverse opened this issue 6 months ago • 8 comments

After updating to IntelliJ IDEA 2025.02, I still see the settings from the Env plugin, but when I run the application, it starts without the environment variables.

Image

The configuration:

  • Java 21
  • Gradle 8.6

dbaloyverse avatar Aug 06 '25 08:08 dbaloyverse

Confirming for Kotlin as well. Took me some time of debugging why my app that worked a few days ago, suddenly stopped :)

jakubgwozdz avatar Aug 06 '25 12:08 jakubgwozdz

If this is of any help, on 2025.1.4.1, while it worked, the entries in idea.log looked like this:

2025-08-04 10:34:52,387 [85832314]   INFO - #o.j.p.g.GradleManager - Instructing gradle to use java from /Users/jakub.g/.sdkman/candidates/java/current
2025-08-04 10:34:52,390 [85832317]   INFO - #o.j.p.g.s.e.GradleExecutionHelper - Passing command-line to Gradle Tooling API: :app:classes --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/ijMapper1.gradle --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/ijresolvers1.gradle --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/ijJvmDebugger1.gradle --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/ijKotlinCoroutineJvmDebugInit1.gradle --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/Build_environment_check1.gradle -Didea.active=true -Didea.version=2025.1.4.1 -Didea.vendor.name=JetBrains

Now on 2025.2 they look a bit different:

2025-08-06 14:31:10,097 [ 609350]   INFO - #o.j.p.g.GradleManager - Instructing gradle to use java from /Users/jakub.g/.sdkman/candidates/java/current
2025-08-06 14:31:10,562 [ 609815]   INFO - #o.j.p.g.s.e.GradleExecutionHelper - Passing command-line to Gradle Tooling API: :app:redacted.envcheck.AppKt.main() --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/ijMapper1.gradle --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/ijJvmDebugger1.gradle --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/ijKotlinCoroutineJvmDebugInit1.gradle --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/addGradleAndroidTestListener1.gradle --init-script /private/var/folders/lc/pkd18gln5nv5ftn6ft5csg240000gn/T/redacted_envcheck_AppKt_main__1.gradle -Didea.active=true -Didea.version=2025.2 -Didea.vendor.name=JetBrains

So it looks like EnvFile is no longer able to inject .env values when app is run using gradle (no matter if "Enable experimental integrations - may break any time" is checked or not. It looks like it finally broke :) ).

But at least EnvFile still works when IntelliJ setting "Build, Execution -> Build Tools -> Gradle -> Build and run using" is set to "IntelliJ".

jakubgwozdz avatar Aug 06 '25 13:08 jakubgwozdz

One more thing: when the app is launched via "Application" run configuration (not e.g. Kotlin) it can read .env file without any plugin like this one: https://www.jetbrains.com/help/idea/program-arguments-and-environment-variables.html#environment_variables

jakubgwozdz avatar Aug 07 '25 09:08 jakubgwozdz

looks like that the intellij changed the way to instance the applications:

cmd.exe /c "..\mvnw.cmd -Didea.version=2025.2 ...

I guess that this broke the integration. It is delegating to the CMD now

josenicomaia avatar Aug 08 '25 16:08 josenicomaia

I believe this is related to https://youtrack.jetbrains.com/issue/KTIJ-13874 . In my case I have a Kotlin Run Configuration. Pre-2025.2 IDEA launched it with a java command line. Now it is generating a gradle task and launching it via the gradle daemon.

jcopenhop avatar Aug 11 '25 19:08 jcopenhop

We use this plugin for our Quarkus, Maven, and JUnit run configurations, and we encounter the same issue with all of them. Is there currently a plan or intention (how) to address this in a future update?

An addition of a internal IntelliJ function does not seem to be planned: https://youtrack.jetbrains.com/issue/IJPL-179804/Run-configurations-Add-ability-to-specify-a-file-that-defines-environment-variables-.env-.yml-etc.

lpieprzyk avatar Aug 19 '25 11:08 lpieprzyk

As a heads up , with the following version:

IntelliJ IDEA 2025.2.2 Preview (Ultimate Edition)
Build #IU-252.26199.7, built on September 3, 2025

And using the classic ui plugin, i am able to use the EnvFile functionality

gpopides avatar Sep 10 '25 14:09 gpopides

https://github.com/aws/aws-toolkit-jetbrains/issues/5964 looks to be the same issue, so it does not appear to be a EnvFile specific issue.

tresni avatar Sep 15 '25 22:09 tresni