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

评论操作 固定链接

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.

0
评论操作 固定链接

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
评论操作 固定链接

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.

4
评论操作 固定链接

" ... 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.

2
评论操作 固定链接

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.

1
评论操作 固定链接

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

请先登录再写评论。