FluentTerminal
FluentTerminal copied to clipboard
Environment variable are not realoaded unless you Repair FluentTerminal
Use case
- Run FlunetTerminal and use PowerShell as terminal (I use Powershell Core 6.1)
- Add/remove/edit an environment variable
- Open a new terminal tab to see the change in the environment variable
- The change is not applied
- Close all FluentTerminal tabs and launch again a terminal
- The change is not applied
Workaround
Under Windows 10, go to Apps & Feature, look for FluentTerminal, go to Advanced Options, under Reset, click Repair. The environment variable are reload correctly.
You will need to close all windows and the system tray component, only then will relaunchinv the app let you see changes in environment variables.
Hi @Riebart, thanks for the quick reply. I did not noticed the tray icon before and I now moved it to be always visible. 👍 However, I don't understand why the variables are not reloaded if I open a new tab with a new session of PowerShell. If the environment variable are not reloaded from scretch, does it implies that they also share other things/resources? I'm asking this just to be aware to what is going on under the hood 😄
The reason that you need to restart the system tray service is that the terminal windows you see are just the front end to the shell processes. Those shell processes (In your case, powershell.exe
) are spawned by the system tray service, and then your windows connect to the system tray service, and the text you see/send passes back and forth over a connection between the window and the system tray service.
So when you change an environment variable, that change is only reflected in new processes, and spawned terminals will only inherit the old environment (before you made your changes) that the system tray service was launched with originally.
We might be able to improve this with ConPTY since we get more control on how the processes are created
@Riebart thanks for the explanation. It's all clear 👍
@felixse thanks for reaching out and for considering an improvement for FluentTerminal. My two cents here is that, from a user perspective (and even more from a Developer perspective), is much more intuitive that, by opening a new, say, powershell tab, the new terminal is like a new process and everything is started anew, including environment variable. If contrarily this is not the case, I suggest to make it clear in the documentation/wiki/FAQ 😃
By the way, great work with FT. I really like it and use it on a daily-basis 🎉
PS: what is the module name (or whatever it is) that change your terminal prompt line as in the screenshot image of the home project page? It's really cool and similar to the one present in Debian!
I totally agree with you on this, I just didn't come around to address this issue so far.
I have described my setup here but you can also achieve similar results with the fish shell and oh-my-fish or zsh and oh-my-zsh
@felixse great, thanks for sharing your opinion about this matter. I'm looking forward to further updates on this issue 👍
Thanks for the setup instruction, I finally have a very cool theme as well 🎉
It is important to understand that this behaviour is almost ubiquitous. Cmder also behaves like this, as well as the standard terminal emulators on Ubuntu (you need to configure them run the shell command as a login shell to get it to load the new environment files on launch). Solving this, in the unix world, is done by the shell (bash
, etc...), not the terminal emulator (xterm, etc...).
At it's core, it is because environment variables are inherited from parent processes, and without special actions taken by the process (unix shells will typically read profile scripts in /etc/profile.d, and the user's home directory when started, with the specific scripts being read depending on whether the shell is started interactively or not), changes to the system environment will not propagate to those grandchild processes.
With ConPTY, we may be able to do something about this, but a portable solution would be adding scripts for your powershell profiles that re-read the system environment, and insert it when the process is launched, like bash
and other unix shells do.
It is also possible to refresh environment variable without restart using the refreshenv
command, I suggest implementing an auto-run of this command each time a new tab is created. Thanks
I have no idea how this working, I have the same problem as the title, has check on the tray icon and all the running app, nothing is running FluentTerminal but still can't recognize the path environment, then I close the Grove Music
which is window 10 app and run FluentTerminal again it now recognize, enough for this
- Exit all Fluent terminals :(
- Start > find Fluent (don't open) > right click and select App Settings > turn off Background Apps and also click "Terminate" down below
- Reopen fluent. It should see the changes
It is mostly no different than "repair"ing as suggested above. But I believe this different way can help understand the cause. It looks like, closing all windows is not quitting the app, and the app is only refreshing env vars on start up.
It is also possible to refresh environment variable without restart using the
refreshenv
command, I suggest implementing an auto-run of this command each time a new tab is created. Thanks
You could just add it to your terminal profile
Yes, but this should be default behavior should be default, since expected by most users, which is why this issue exists.
It has been nearly five years, and this problem still exists ...
In any case, this problem affects the experience
Still an issue in April 2024. Pulled out my hair before realizing it was Fluent that was having the issue.