Refreshing environment variables

已回答

Hello,
Is there any way to get IntelliJ to refresh Windows environment variables, e.g. M2_HOME, JBOSS_HOME, etc from within Ant or Maven build files?

E.g. from Ant build.xml:
<property environment="osenv"/>
<property name="maven.home.bin" value="${osenv.M2_HOME}/bin" /
>

It seems that if you change any environment variable in the OS you need to restart IntelliJ for the new values to be refreshed in the scripts.
Thanks
AndyB

7

No, there is no way. Just like with any other Windows executable, system-level changes to the environment variables are only propagated to the process when it is restarted.

1
Avatar
Permanently deleted user

This is super old, but seeming still relevant.  I will be bold and say it is incorrect to state "there is no way".  If you can override env vars in run configs, then It should be totally doable.  This would make a great feature IMO.  Perhaps it's possible via a plugin as an alternative to an integrated feature.  I just did a quick search, but turned up nothing obvious.

9
Avatar
Permanently deleted user

There must be a way to do it, if when you first start pycharm or something similar it will load your system variables. So even if pycharm can't automatically detect that things have changed, there should be an option to reload this information.

Or does anyone know if there is now a plugin that does this

2

This is becoming more relevant due to AWS authentication tokens.  The tokens last a maximum of 12 hours and IntelliJ must be restarted to pick-up the new values.

6

" ... Just like with any other Windows executable, system-level changes to the environment variables are only propagated to the process when it is restarted."

 

Is there a nice reason why File -> Invalidate Caches / Restart ... -> Restart does not do the trick?

I can see that WebStorm restarts with new PID, but variables are not updated.

 

EDIT: Closing my IDE and reopening refreshes variables nicely, but I would assume that restart triggered within IDE also does it.

6

" ... Just like with any other Windows executable, system-level changes to the environment variables are only propagated to the process when it is restarted."

 

Is there a nice reason why File -> Invalidate Caches / Restart ... -> Restart does not do the trick?

I can see that WebStorm restarts with new PID, but variables are not updated.

 

EDIT: Closing my IDE and reopening refreshes variables nicely, but I would assume that restart triggered within IDE also does it.

 

OMG, it took me an hour to fix it, I need to close/reopen IDE manually, trigger Restart/Invalidate & restart won't help.

4

Just waking up this topic once more.
Strictly from the user experience standpoint if there is any effort to this effect can be made that will be ideal.

My main problem is that when I restart an IDE session it will be a while for the index check and such to kick in and complete and worse yet, I often forget to restart the IDE and then chasing a bug that I have meant to fix that relates to setting different values in $env. 

I think you can reload env values via [System.Environment] in Powershell so technically we should be able to do things like that and re-propagate the env values when the IDE starts a new sub-process.

 

0

Manabu

> My main problem is that when I restart an IDE session it will be a while for the index check

If IDE performs reindex on every start, it's a bug, it should not happen, please report at https://youtrack.jetbrains.com/newIssue?project=IDEA with the logs attached (Help | Collect Logs and Diagnostic Data).

At the moment we do not have plans to reload environment variables on the fly.

0

Hi Serge, thank you for your response. I did not mean to say the full indexing, but it does take a bit of time to check things, and then I must restart the debug session etc which also will take some time, in my case, sbt to do it's thing.  Fully understand this isn't a priority. I was looking to see if anything has been done about this as this has been a bit annoying.

On a positive note, I am using the type-aware indexes IJ generates, and my workflow has truly become search centric for functions, variables and amazing that I can use IJ to work in TypeScript, Scala, Java, and Python. So indexing is worth the wait for the first time the project loads. It's been wonderful.

 

0

Even if the IDE could reload the environment, you will still need to restart your app to see these changes.

2

This happened to me today with pycharm and took me down a useless 16 hour path. Still trying to resolve but now know the issue.

0

I'm currently facing the same issue, is there any workaround for this?

0

Can you at least let the user invalidate the current environment variables loaded by the IDE?

I'm currently using Intellij and I'm having a very frustrating experience while trying to sync my project dependencies that live in an AWS private repo.  I have logged into it using environment variables. No matter how many times I restart the IDE and how much I invalidate the cache, it still doesn't see the environment variables that hold the credentials.

This makes the Gradle plugin completely useless since I can't even use it to build or resync the project. I have to run a damn command.

1

No matter how many times I restart the IDE and how much I invalidate the cache, it still doesn't see the environment variables that hold the credentials

Normally, environment variables should be reloaded after the IDE restart. Do you have Toolbox application installed? Try to restart not only IntelliJ process but Toolbox application as well

Related issue TBX-3549

If the problem remains, please contact our support team directly at https://intellij-support.jetbrains.com/hc/en-us/requests/new for a further assistance

0

Normally, environment variables should be reloaded after the IDE restart. Do you have Toolbox application installed? Try to restart not only IntelliJ process but Toolbox application as well

Hi Egor Klepikov I don't have the Toolbox application installed. And I'm facing that issue: env. variables are not updated after IDEA restart/validate cache



how can I validate env. variables to make gradle work?
any ideas are much appreciated

Thanks

0

Start IntelliJ IDEA from the command line per https://intellij-support.jetbrains.com/hc/en-us/articles/360011901879-How-to-start-IDE-from-the-command-line from the terminal where the new environment variables are visible. Does IDE see them?

You can use https://plugins.jetbrains.com/plugin/10998-environment-variable-settings-summary to check what env vars are available to the IDE.

If it doesn't work, please provide more details about the issue via the support ticket at https://intellij-support.jetbrains.com/hc/requests/new.

0

请先登录再写评论。