Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variable are not realoaded unless you Repair FluentTerminal #131

Open
claudiofantacci opened this issue Nov 16, 2018 · 15 comments
Labels
bug Something isn't working

Comments

@claudiofantacci
Copy link

Use case

  1. Run FlunetTerminal and use PowerShell as terminal (I use Powershell Core 6.1)
  2. Add/remove/edit an environment variable
  3. Open a new terminal tab to see the change in the environment variable
    • The change is not applied
  4. 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.

@Riebart
Copy link
Contributor

Riebart commented Nov 16, 2018

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.

@claudiofantacci
Copy link
Author

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 😄

@Riebart
Copy link
Contributor

Riebart commented Nov 16, 2018

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.

@felixse
Copy link
Owner

felixse commented Nov 17, 2018

We might be able to improve this with ConPTY since we get more control on how the processes are created

@felixse felixse added the bug Something isn't working label Nov 17, 2018
@claudiofantacci
Copy link
Author

@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!

@felixse
Copy link
Owner

felixse commented Nov 17, 2018

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

@claudiofantacci
Copy link
Author

@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 🎉

@Riebart
Copy link
Contributor

Riebart commented Nov 18, 2018

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.

@KaKi87
Copy link

KaKi87 commented Jun 5, 2021

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

@dim0147
Copy link

dim0147 commented Jun 12, 2021

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

@dkavraal
Copy link

dkavraal commented May 12, 2022

  1. Exit all Fluent terminals :(
  2. Start > find Fluent (don't open) > right click and select App Settings > turn off Background Apps and also click "Terminate" down below
  3. 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.

@fennelhans
Copy link

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

@KaKi87
Copy link

KaKi87 commented May 12, 2022

Yes, but this should be default behavior should be default, since expected by most users, which is why this issue exists.

@syrm-ll
Copy link

syrm-ll commented Feb 20, 2023

It has been nearly five years, and this problem still exists ...

In any case, this problem affects the experience

@SeyelentEco
Copy link

Still an issue in April 2024. Pulled out my hair before realizing it was Fluent that was having the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants