-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Bug] Cmder not expanding variable in environment variable #2845
Comments
This is a funny one: At first, I was able to reproduce it (using Cmder v1.3.21), but eventually it seemed to stop happening. It only reproduced with Cmder.exe, never with only ConEmu.exe or cmd.exe by themselves. I reviewed the Cmder launcher source code and found that these lines run after CreateProcess: cmder/launcher/src/CmderLauncher.cpp Lines 473 to 474 in 4aefd0b
That's a bit strange: So the Cmder.exe launches ConEmu.exe, and then it attempts to force all processes on the computer to reload and reset their environments. That's probably not a good idea to be doing that every time Cmder.exe launches anyway, but it's especially strange because it's forcing a race condition:
I was curious if source history could shed any light on this, and indeed it does.
Running those lines before spawning ConEmu.exe will make launching Cmder slow, because it synchronously waits for all processes on the computer to receive the message and reload their environments. But running those lines after spawning ConEmu.exe removes their supposed benefits, while also creating a race condition where now sometimes the environment may briefly not have the right content while starting a tab. (Note that it risks also creating race conditions for all other processes on the computer every time those lines run.) @DRSDavidSoft @daxgames @MartiUK I would recommend to remove those two lines. Under the best of conditions, they have no effect on ConEmu. But they always interfere with all other processes on the computer. And when the timing happens just right, they can negatively affect ConEmu while it's trying to start a new tab. Because it's a race condition and isn't consistent, I can't prove that it's what's causing this issue reported by @t-ricci-digit. But the lines really do not belong, and for the past 7 years they haven't been having whatever effect was originally intended. |
@chrisant996 Thank you for your insights. I agree that the broadcast message is unnecessary for ConEmu and potentially harmful for other running apps. It could introduce an unnecessary delay right after launching ConEmu and interfere with other applications. If the broadcast message is not doing anything noticeable or useful, then it would be a good idea to remove it from the launcher code and avoid sending an unnecessary message to all top-level windows in the system, which even includes the disabled or invisible unowned windows. And of course, if we really need to send the The only scenario that I can think of where this message would be useful is if the environment variables that are set by There are several environment variables that are set by
The environment variables that are set by |
@DRSDavidSoft environment variables set into the Cmder.exe process are guaranteed to be inherited by CreateProcess, because Cmder.exe passes NULL for the environment block parameter. But the WM_SETTINGCHANGE message would be useless for that anyway. It tells processes "reload your environment from the registry". It has nothing to do with propagating environment variables from one process to another. |
Version Information
Cmder Edition
Cmder Full (with Git)
Description of the issue
If a Windows Environment Variable from system settings is defined using another environment variables it is not expanded when using CMD.exe inside Cmder.
Example:
ANDROID_HOME=%LOCALAPPDATA%\Android\Sdk
(not just ANDROID_HOME other similar variables do not get expanded as well)
When opening CMD.exe directly (without Cmder) the path is expanded correctly as follows:
If I print the same variable in CMD.exe from within Cmder then the path is not correct:
This means that when building an android application from the command line it only works in CMD.exe directly but fails from within Cmder
How to reproduce
echo %ANDROID_HOME%
and press ENTERAdditional context
Setting the environment variables from the Cmder settings: startup/environement the variables are expanded correctly.
A workaround for me is currently to define the variables twice: in the windows system settings and in Cmder settings.
It would be best if the variable expansion is working without the need to also duplicate it in Cmder
Checklist
The text was updated successfully, but these errors were encountered: