-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Installer does not find schtasks if NoDefaultCurrentDirectoryInExePath=1 #2319
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
Comments
In installer/environment.inc.iss, function SetEnvStrings has a comment talking about "environment variable names that are expanded at evaluation time": https://github.com/git-for-windows/build-extra/blob/a15a4b28caa9178bbaa3963c8940ac4e417e1ac3/installer/environment.inc.iss#L56-L61 As far as I can tell, when cmd.exe searches for an executable file, it does not expand any environment variable names that are listed in the value of the PATH environment variable. I believe those should instead be expanded when the value is copied from the Registry to the environment variable block of a process. On that basis, it seems wrong to me that the Expandable parameter of function SetEnvStrings affects only the type of the Registry values and does not affect the string passed to SetEnvironmentVariable. Perhaps it should call ExpandEnvironmentStringsW, but I don't know Inno Setup scripting. |
I suppose an easy workaround might be to make the installer call |
This comment has been minimized.
This comment has been minimized.
This command-line should be correct, no?
I once encountered such a
But this only affects values obtained from the registry, correct? Is your default |
AFAIK, all the command lines are correct, just the
If I start Command Prompt from the Start menu, then the cmd.exe process gets an environment in which And, if I double-click Git-2.23.0-64-bit.exe, then that process likewise gets a correct Does this answer your question or do you mean something else with "default PATH"? |
@dscho, are you able to test with I found it useful to configure Process Monitor to display only events in which Operation is Process Start. |
So, under which circumstances does it not get a correct |
Git-2.23.0-64-bit.tmp starts several cmd.exe child processes. The first few of them get the correct |
Isn't that call's |
Yes, it is.
That only makes |
Good point.
I guess that would work, but it does make me uneasy. How about changing Or we go the whole nine yards and expand all environment variables, with something like this: function ExpandEnvironmentStrings(lpSrc,lpDst:String;nSize:DWORD):DWORD;
#ifdef UNICODE
external '[email protected] stdcall delayload';
#else
external '[email protected] stdcall delayload';
#endif
function ExpandEnvironmentVariables(S:String):String;
var
Size:DWORD;
begin
Size:=ExpandEnvironmentStrings(S,'',0);
if (Size=0) then
LogError('Could not determine size of expanded "'+S+'"');
else begin
SetLength(Result,Size);
if (ExpandEnvironmentStrings(S,Result,Size)=0) then
LogError('Could not expand "'+S+'"');
end;
end; and then using that function in that SetEnvironmentVariable(VarName,ExpandEnvironmentVariables(Path)); @KalleOlaviNiemitalo what do you think? |
@KalleOlaviNiemitalo if you think this is worth doing, can you
|
@dscho, I think it is better to expand all environment variables (when However, perhaps the
For contractual reasons, I am not sure I can do that. |
Unfortunately, the implied "contract" (in a real sense, not in a legal one) of Open Source is that you don't get to demand from others that they fix your problems. It is ultimately your problem to solve. You might get lucky, of course, maybe anyone else feels like addressing this issue and you will benefit from their work. |
I hope they will benefit from my analysis here. |
I think a more correct statement on your part would have been "I hope that there will be anybody". If I were you, I wouldn't get my hopes up. Personally, I don't like to feel being taken advantage of, and this here ticket feels very much so, to me. |
Closing this stale ticket. |
Setup
Windows 7 Professional SP1 64-bit
defaults?
to the issue you're seeing?
The
NoDefaultCurrentDirectoryInExePath
value atHKEY_CURRENT_USER\Environment
has typeREG_SZ
and data1
.The
Path
value atHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
starts with%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
. The type of that value isREG_EXPAND_SZ
, which seems correct to me.The
Path
value atHKEY_CURRENT_USER\Environment
lists unrelated directories and has no percent signs in it. The type of that value isREG_SZ
.Details
Not applicable. The error occurs during installation.
Minimal, Complete, and Verifiable example
this will help us understand the issue.
Double-click Git-2.23.0-64-bit.exe in Windows Explorer and select the options described above, plus "Check daily for Git for Windows updates".
Installation succeeds without errors.
An error message pops up:
I then click OK and installation continues.
URL to that repository to help us with testing?
Not applicable.
Process Monitor
Process Monitor shows that
Git-2.23.0-64-bit.tmp
startsC:\Windows\system32\cmd.exe
with the command line"C:\Windows\system32\cmd.exe" /C schtasks /Create /F /TN "Git for Windows Updater" /XML "C:\Users\Kalle\AppData\Local\Temp\is-6PE04.tmp\auto-updater.xml" >"C:\Users\Kalle\AppData\Local\Temp\is-6PE04.tmp\remove-autoupdate.log" 2>"C:\Users\Kalle\AppData\Local\Temp\is-6PE04.tmp\remove-autoupdate.err"
and with aPath
environment variable whose value starts with literally%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
, rather thanC:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
. Thecmd.exe
process then tries to openC:\Windows\system32\%SystemRoot%\system32\
and fails.When the
Git-2.23.0-64-bit.tmp
process starts, it gets aPath
environment variable whose value correctly starts withC:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
. It also starts severalcmd.exe
processes with this correctPath
value, e.g. when it runs"C:\Windows\system32\cmd.exe" /C .\mingw64\bin\git.exe config --system "ssh.variant" "putty" >"C:\Users\Kalle\AppData\Local\Temp\is-6PE04.tmp\config-set.out" 2>"C:\Users\Kalle\AppData\Local\Temp\is-6PE04.tmp\config-set.err"
(source?). However, thePath
variable is already wrong when it runs"C:\Windows\system32\cmd.exe" /C .\mingw64\bin\git.exe config --system "core.editor" "nano.exe" >"C:\Users\Kalle\AppData\Local\Temp\is-6PE04.tmp\config-set.out" 2>"C:\Users\Kalle\AppData\Local\Temp\is-6PE04.tmp\config-set.err"
(source?).The working directory of the
cmd.exe
process isC:\Windows\system32\
, but because the environment also containsNoDefaultCurrentDirectoryInExePath=1
,cmd.exe
does not search that directory when it is not listed inPATH
.The text was updated successfully, but these errors were encountered: