conemu and console2 emulators not getting new path variable
Asked Answered
C

3

21

I thought maybe it was a system issue but recently did a fresh install (win7 64bit) and a clean install of conemu (had same problem with both conemu and console2 on old win32 system). Also everything I find researching has to do with adding variables via the command line. I'm doing this through Start->Control Panel->System->Advanced System Settings and then restarting the console. cmd picks up the path correctly.

When I manually add a new path to the system or user PATH variable and then restart the console and echo %path% it has not re-loaded the new PATH variable.

cmd.exe:

C:\Users\lotus>echo %path%
C:\Python33\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\
System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\PHP;C:\ProgramData\
Composer\bin;C:\PHP;C:\PHP\ext;C:\Ruby200-x64\bin;C:\Users\lotus\AppData\Roaming
\npm

conemu:

C:\Program Files\ConEmu>echo %path%
C:\Program Files\ConEmu\ConEmu;C:\Program Files\ConEmu;C:\Python33\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Ruby200-x64\bin

I know there is a extra C:\PHP but that's another issue. I still have the same problem if I remove that.

Thanks

Chicago answered 10/6, 2013 at 18:46 Comment(0)
E
29

When you are using alternative tab based terminals like ConEmu or Console2, you need to restart the terminal, not a single console (read tab)!

This is because child processes inherit their environment their direct parent process, not from the system!

Sometimes explorer (or whatever shell you are using to start ConEmu) needs to be restarted, as in you have to kill explorer.exe, so your start menu disappears and relaunch it from task manager. If all else fails, log off and on again.

Earshot answered 11/6, 2013 at 14:33 Comment(10)
"When you are using alternative terminals like ConEmu or Console2, you need to restart not a console (read tab), but while terminal!" Not sure what you mean by this. I closed conemu completely and then reopen it. I also tried restarting explorer via task manager and that didn't work. But logging off and back on works. It's slightly irritating to have to do but saves a system restart.Chicago
I've never seen that personally, and can't understand how that may happens... Seems like Explorer or OS bug. I've write about restating the whole terminal, because you have not said that "conemu was closed and restarted again".Earshot
Oh ok yeah I completely closed it. Maybe researching what all shuts down on a logoff (explorer.exe, dwm.exe, winlogon.exe?, etc.) I can figure out if there is a way to do it without actually logging off. But if not, it's not a big deal to log off. ThanksChicago
This works too :-) #172088Chicago
I was opening comemu from a "explorer" window (there was no comemu process). Only got the new path after closing the explorer window.Margotmargrave
@RicardoRivaldo Do you understand what is the inheritance? ConEmu always inherits all environment from the parent process. If the parent has "wrong" environment neither child process (e.g. ConEmu) can gets "right" one.Earshot
@Earshot Yes, but this is only with comemu. Windows command prompt (regular windows console) does not have this incorrect behavior. You change the environment and the next console will always get the new config.Margotmargrave
It's hard to believe. May be you are running them different ways.Earshot
@Chicago Even if you close all the tabs and comemu closes, it might not be completely closed, it might have started in the background when the pc started so is always there unless you end task it from TaskManager.Hotchpot
Even it is "there" you do not need to use TaskManager. ConEmu icon must be in the taskbar status area (TSA).Earshot
P
3

Even if ConEmu is closed, there is a ConEmu64.exe process. Need to kill it.

Posen answered 13/6, 2014 at 21:42 Comment(1)
That may be if user have chosen to minimize (or hide to the notification area) the GUI (main ConEmu window) instead of terminate it.Earshot
T
0

Create this user settings ConEmu file:

"%USERPROFILE%\.conemu\CmdInit.cmd"

Put this code in the file CmdInit.cmd:

:: Retrieve User & System PATHS from the registry
for /f "tokens=2,*" %%A in ('reg query "HKCU\Environment" /v Path ^| find "Path"') do set USER_PATH=%%B
for /f "tokens=2,*" %%A in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path ^| find "Path"') do set SYS_PATH=%%B

:: Merge PATHS with ConEmu's PATH
set "PATH=%ConEmuBaseDir%\Scripts;%USER_PATH%%SYS_PATH%"

Now every time ConEmu runs it will update the paths.

Docs:
ConEmu Configuring Cmd Prompt

Trejo answered 11/3 at 13:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.