Navigation Menu

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

Exception during registration: The Process object must have the UseShellExecute property set to false in order to redirect IO streams #505

Closed
2 of 4 tasks
carlos-algms opened this issue Oct 27, 2021 · 7 comments · Fixed by #531
Labels
auth-issue An issue authenticating to a host external Relating to an external partner, team, or library

Comments

@carlos-algms
Copy link

Which version of GCM Core are you using?

λ git-credential-manager-core --version 
2.0.567+3047faf390

Which Git host provider are you trying to connect to?

  • Other - please describe
    • gitlab

Can you access the remote repository directly in the browser using the remote URL?

From a terminal, run git remote -v to see your remote URL.

  • Yes
  • No, I get a permission error
  • No, for a different reason - please describe

Expected behavior

I am authenticated and my Git operation completes successfully.

Actual behavior

  • I am authenticated;
  • Git operation completes successfully;
  • No exception is visible on the console
  • An extraneous exception file is created in the current path
λ git pull
info: detecting host provider for 'https://gitlab.com/'...
info: detecting host provider for 'https://gitlab.com/'...
Already up to date.
  • File created path:
    =\system-commandline-sentinel-files\dotnet-suggest-registration-git-credential-manager-core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
    (the folder name is really just =)

  • File content:

Exception during registration:
System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.CommandLine.Invocation.Process.StartProcess(String command, String args, String workingDir, Action`1 stdOut, Action`1 stdErr, ValueTuple`2[] environmentVariables)
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_1>d.MoveNext()

Logs

Set the environment variables GCM_TRACE=1 and GIT_TRACE=1 and re-run your Git command. Review and redact any private information and attach the log.

GCM_TRACE=1 GIT_TRACE=1 git pull - Click to expand!
GCM_TRACE=1 GIT_TRACE=1 git pull
10:48:42.867239 exec-cmd.c:237          trace: resolved executable dir: D:/apps/PortableGit/mingw64/libexec/git-core
10:48:42.871239 git.c:455               trace: built-in: git pull
10:48:42.873239 run-command.c:666       trace: run_command: git fetch --update-head-ok
10:48:42.889255 exec-cmd.c:237          trace: resolved executable dir: D:/apps/PortableGit/mingw64/libexec/git-core
10:48:42.892240 git.c:455               trace: built-in: git fetch --update-head-ok
10:48:42.896239 run-command.c:666       trace: run_command: GIT_DIR=.git git remote-https origin https://gitlab.com/my-org/my-repo.git
10:48:42.911238 exec-cmd.c:237          trace: resolved executable dir: D:/apps/PortableGit/mingw64/libexec/git-core
10:48:42.913239 git.c:744               trace: exec: git-remote-https origin https://gitlab.com/my-org/my-repo.git
10:48:42.913239 run-command.c:666       trace: run_command: git-remote-https origin https://gitlab.com/my-org/my-repo.git
10:48:42.930243 exec-cmd.c:237          trace: resolved executable dir: D:/apps/PortableGit/mingw64/libexec/git-core
10:48:43.183498 run-command.c:666       trace: run_command: '"D:/apps/PortableGit/mingw64/libexec/git-core/git-credential-manager-core.exe" get'
Reading from stdin via: C:\Users\c_a_g\AppData\Local\Temp\code-stdin-ktr
10:48:43.369008 ...\Application.cs:95   trace: [RunInternalAsync] Version: 2.0.567.18224
10:48:43.374008 ...\Application.cs:96   trace: [RunInternalAsync] Runtime: .NET Framework 4.0.30319.42000
10:48:43.375009 ...\Application.cs:97   trace: [RunInternalAsync] Platform: Windows (x86-64)
10:48:43.375009 ...\Application.cs:98   trace: [RunInternalAsync] OSVersion: 10.0 (build 19043)
10:48:43.376012 ...\Application.cs:99   trace: [RunInternalAsync] AppPath: D:\apps\PortableGit\mingw64\libexec\git-core\git-credential-manager-core.exe
10:48:43.376012 ...\Application.cs:100  trace: [RunInternalAsync] Arguments: get
10:48:43.433118 ...GitCommandBase.cs:33 trace: [ExecuteAsync] Start 'get' command...
10:48:43.442118 ...GitCommandBase.cs:47 trace: [ExecuteAsync] Detecting host provider for input:
10:48:43.445120 ...GitCommandBase.cs:48 trace: [ExecuteAsync]   protocol=https
10:48:43.445120 ...GitCommandBase.cs:48 trace: [ExecuteAsync]   host=gitlab.com
10:48:43.523120 ...viderRegistry.cs:147 trace: [GetProviderAsync] Performing auto-detection of host provider.
10:48:43.566120 ...viderRegistry.cs:152 trace: [GetProviderAsync] Auto-detect probe timeout is 2 ms.
10:48:43.568126 ...viderRegistry.cs:160 trace: [GetProviderAsync] Checking against 3 host providers registered with priority 'Normal'.
10:48:43.570121 ...viderRegistry.cs:175 trace: [GetProviderAsync] Querying remote URL for host provider auto-detection.
info: detecting host provider for 'https://gitlab.com/'...
10:48:43.572118 ...pClientFactory.cs:58 trace: [CreateClient] Creating new HTTP client instance...
10:48:44.390474 ...etHostProvider.cs:70 trace: [IsSupported] Host isn't supported as Bitbucket
10:48:44.390474 ...viderRegistry.cs:160 trace: [GetProviderAsync] Checking against 1 host providers registered with priority 'Low'.
10:48:44.401564 ...GitCommandBase.cs:50 trace: [ExecuteAsync] Host provider 'Generic' was selected.
10:48:44.403993 ...\HostProvider.cs:126 trace: [GetCredentialAsync] Looking for existing credential in store with service=https://gitlab.com account=...
10:48:44.483510 ...\HostProvider.cs:140 trace: [GetCredentialAsync] Existing credential found.
10:48:44.484681 ...GitCommandBase.cs:54 trace: [ExecuteAsync] End 'get' command...
10:48:44.891565 run-command.c:666       trace: run_command: '"D:/apps/PortableGit/mingw64/libexec/git-core/git-credential-manager-core.exe" store'
10:48:45.039297 ...\Application.cs:95   trace: [RunInternalAsync] Version: 2.0.567.18224
10:48:45.054921 ...\Application.cs:96   trace: [RunInternalAsync] Runtime: .NET Framework 4.0.30319.42000
10:48:45.054921 ...\Application.cs:97   trace: [RunInternalAsync] Platform: Windows (x86-64)
10:48:45.054921 ...\Application.cs:98   trace: [RunInternalAsync] OSVersion: 10.0 (build 19043)
10:48:45.054921 ...\Application.cs:99   trace: [RunInternalAsync] AppPath: D:\apps\PortableGit\mingw64\libexec\git-core\git-credential-manager-core.exe
10:48:45.056408 ...\Application.cs:100  trace: [RunInternalAsync] Arguments: store
10:48:45.110795 ...GitCommandBase.cs:33 trace: [ExecuteAsync] Start 'store' command...
10:48:45.121773 ...GitCommandBase.cs:47 trace: [ExecuteAsync] Detecting host provider for input:
10:48:45.122774 ...GitCommandBase.cs:48 trace: [ExecuteAsync]   protocol=https
10:48:45.123774 ...GitCommandBase.cs:48 trace: [ExecuteAsync]   host=gitlab.com
10:48:45.123774 ...GitCommandBase.cs:48 trace: [ExecuteAsync]   username=my-email@provider.com
10:48:45.123774 ...GitCommandBase.cs:48 trace: [ExecuteAsync]   password=********
10:48:45.198610 ...viderRegistry.cs:147 trace: [GetProviderAsync] Performing auto-detection of host provider.
10:48:45.230253 ...viderRegistry.cs:152 trace: [GetProviderAsync] Auto-detect probe timeout is 2 ms.
10:48:45.232211 ...viderRegistry.cs:160 trace: [GetProviderAsync] Checking against 3 host providers registered with priority 'Normal'.
10:48:45.234278 ...viderRegistry.cs:175 trace: [GetProviderAsync] Querying remote URL for host provider auto-detection.
info: detecting host provider for 'https://gitlab.com/'...
10:48:45.238212 ...pClientFactory.cs:58 trace: [CreateClient] Creating new HTTP client instance...
10:48:46.176033 ...etHostProvider.cs:70 trace: [IsSupported] Host isn't supported as Bitbucket
10:48:46.176033 ...viderRegistry.cs:160 trace: [GetProviderAsync] Checking against 1 host providers registered with priority 'Low'.
10:48:46.176033 ...GitCommandBase.cs:50 trace: [ExecuteAsync] Host provider 'Generic' was selected.
10:48:46.184015 ...\HostProvider.cs:160 trace: [StoreCredentialAsync] Storing credential with service=https://gitlab.com account=my-email@provider.com...
10:48:46.263545 ...\HostProvider.cs:162 trace: [StoreCredentialAsync] Credential was successfully stored.
10:48:46.264558 ...GitCommandBase.cs:54 trace: [ExecuteAsync] End 'store' command...
10:48:46.629973 run-command.c:666       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
10:48:46.654785 run-command.c:666       trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
10:48:46.667694 exec-cmd.c:237          trace: resolved executable dir: D:/apps/PortableGit/mingw64/libexec/git-core
10:48:46.669704 git.c:455               trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs
10:48:46.683769 run-command.c:1625      run_processes_parallel: preparing to run up to 1 tasks
10:48:46.683769 run-command.c:1657      run_processes_parallel: done
10:48:46.683769 run-command.c:666       trace: run_command: git maintenance run --auto --no-quiet
10:48:46.698756 exec-cmd.c:237          trace: resolved executable dir: D:/apps/PortableGit/mingw64/libexec/git-core
10:48:46.701742 git.c:455               trace: built-in: git maintenance run --auto --no-quiet
10:48:46.709705 run-command.c:666       trace: run_command: git merge FETCH_HEAD
10:48:46.722749 exec-cmd.c:237          trace: resolved executable dir: D:/apps/PortableGit/mingw64/libexec/git-core
10:48:46.725703 git.c:455               trace: built-in: git merge FETCH_HEAD

@carlos-algms carlos-algms added the auth-issue An issue authenticating to a host label Oct 27, 2021
@mjcheetham mjcheetham added the external Relating to an external partner, team, or library label Nov 2, 2021
@mjcheetham
Copy link
Collaborator

Hmm.. this looks like a problem with the System.CommandLine library and redirection of standard input/output streams.

What terminal application are you using out of interest? Also what OS (and version) are you using? Thanks

mjcheetham added a commit to mjcheetham/git-credential-manager that referenced this issue Nov 15, 2021
Update the System.CommandLine package to 2.0.0-beta1.21216.1 to
hopefully fix some problems with dotnet-suggest registration caused by
Process::UseShellExecute differences between .NET Framework and .NET
(Core).

jonsequitur/command-line-api@ad22b69
dotnet/command-line-api#1254
git-ecosystem#505
@nicholass-alcidion
Copy link

I have been getting this same error when using Windows Terminal + Ubuntu + WSL2 - I was able to successfully pull last night, but am unable to this morning.

In an effort to get this working, I have cloned this repo, built and installed the locally build copy and am continuing to get this error:

PS C:\Users\...\Documents\Git-Credential-Manager-Core> & 'C:\Program Files (x86)\Git Credential Manager Core\git-credential-manager-core.exe' --version
2.0.604+7c4381cb75
❯ /mnt/c/Program\ Files\ \(x86\)/Git\ Credential\ Manager\ Core/git-credential-manager-core.exe

Unhandled Exception:
System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
  at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo) [0x00060] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at System.Diagnostics.Process.Start () [0x00032] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
  at GitCredentialManager.PlatformUtils.GetOSVersion () [0x000e4] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.PlatformUtils.GetPlatformInformation () [0x00005] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.Application.RunInternalAsync (System.String[] args) [0x00120] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.Program.Main (System.String[] args) [0x0008f] in <338aeadd19e34379a3b46ee679555677>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
  at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo) [0x00060] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at System.Diagnostics.Process.Start () [0x00032] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
  at GitCredentialManager.PlatformUtils.GetOSVersion () [0x000e4] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.PlatformUtils.GetPlatformInformation () [0x00005] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.Application.RunInternalAsync (System.String[] args) [0x00120] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.Program.Main (System.String[] args) [0x0008f] in <338aeadd19e34379a3b46ee679555677>:0

Trace log

 1 ❯ GCM_TRACE=1 GIT_TRACE=1 git pull
09:07:05.860460 git.c:439               trace: built-in: git pull
09:07:05.861842 run-command.c:663       trace: run_command: git fetch --update-head-ok
09:07:05.862603 git.c:439               trace: built-in: git fetch --update-head-ok
09:07:05.864015 run-command.c:663       trace: run_command: GIT_DIR=.git git-remote-https origin https://alcidion@dev.azure.com/alcidion/Precision/_git/Precision
09:07:06.147460 run-command.c:663       trace: run_command: '/mnt/c/Program\ Files\ \(x86\)/Git\ Credential\ Manager\ Core/git-credential-manager-core.exe get'

Unhandled Exception:
System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
  at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo) [0x00060] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at System.Diagnostics.Process.Start () [0x00032] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
  at GitCredentialManager.PlatformUtils.GetOSVersion () [0x000e4] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.PlatformUtils.GetPlatformInformation () [0x00005] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.Application.RunInternalAsync (System.String[] args) [0x00120] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.Program.Main (System.String[] args) [0x0008f] in <338aeadd19e34379a3b46ee679555677>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
  at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo) [0x00060] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at System.Diagnostics.Process.Start () [0x00032] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
  at GitCredentialManager.PlatformUtils.GetOSVersion () [0x000e4] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.PlatformUtils.GetPlatformInformation () [0x00005] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.Application.RunInternalAsync (System.String[] args) [0x00120] in <638d0763d4a04abf8f0d308a40938326>:0
  at GitCredentialManager.Program.Main (System.String[] args) [0x0008f] in <338aeadd19e34379a3b46ee679555677>:0

mminns pushed a commit to mminns/Git-Credential-Manager that referenced this issue Nov 22, 2021
Update the System.CommandLine package to 2.0.0-beta1.21216.1 to
hopefully fix some problems with dotnet-suggest registration caused by
Process::UseShellExecute differences between .NET Framework and .NET
(Core).

jonsequitur/command-line-api@ad22b69
dotnet/command-line-api#1254
git-ecosystem#505
@mjcheetham
Copy link
Collaborator

@nicholass-alcidion please can you tell me more about your setup? I am unable to reproduce this problem.

What version of Windows Terminal are you using? What version of Ubuntu? What version of Windows? What extra customisations have you made to your prompt? What shell are you using? Bash, csh, zsh, etc?

@mjcheetham mjcheetham reopened this Dec 7, 2021
@nicholass-alcidion
Copy link

Since the above post I have been forced to reinstall windows and even with importing my existing WSL image I am no longer experiencing the issue.

I am on Windows 11, Ubuntu 20.04, Latest Terminal from Windows Store, using Bash and the powerline theme from bash-it.

I think this issue may have been caused by installing mono-runtime into my Ubuntu and having its binfmt entry overwriting the regular WSL entry - such that git.exe from the windows side would not execute.

Since removing mono-runtime I am also no longer able reproduce.

@mjcheetham
Copy link
Collaborator

Closing as not able to reproduce.

@nidefawl
Copy link

I get the same problem when running a git pull from zsh on a Windows Git Bash installation.
Everything seems to work fine, but this stupid = folders is created each time I pull

@nidefawl
Copy link

nidefawl commented Apr 11, 2022

With the latest version (System.CommandLine 2.0.0-beta1.21216.1) I still had =/system-commandline-sentinel-files directories being created when running git pull from zsh (on top of git bash installation)
It creates a single file $CWD/=/system-commandline-sentinel-files/dotnet-suggest-registration-git-credential-manager-core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null with the contents:

Exception during registration:
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.CommandLine.Invocation.Process.StartProcess(String command, String args, String workingDir, Action`1 stdOut, Action`1 stdErr, ValueTuple`2[] environmentVariables)
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_1>d.MoveNext()

So something about dotnet command line completion goes wrong. This in itself is just a warning, not an error.
The problem is that it creates that log file in the current working directory when I run git pull but not when I invoke git-credentials-manager-core.exe directly.

When invoked from git-pull Path.GetTempPath() returned = and the files are created inside the current working directory.
When invoked directly Path.GetTempPath() showed the correct system temp path.

I inspected the process startup environment with Process Monitor.
At some point when git launches a subprocess the TMP environment variable goes from a valid path to empty.
The underlying issue turned out to be an additional empty tmp= environment variable being defined in the initial shell environment.
This again is because C:\Program Files\Git\etc\profile exports tmp even when its not assigned.

I don't know who is to blame here. I just removed the export lowercase tmp and temp from /etc/profile.
Now this error logfile goes to the system temp directory instead of the current working directory.

I did not have this problem when disabling oh-my-zsh

ldennington pushed a commit to ldennington/git-credential-manager that referenced this issue Jun 15, 2022
Update the System.CommandLine package to 2.0.0-beta1.21216.1 to
hopefully fix some problems with dotnet-suggest registration caused by
Process::UseShellExecute differences between .NET Framework and .NET
(Core).

jonsequitur/command-line-api@ad22b69
dotnet/command-line-api#1254
git-ecosystem#505
caixtong pushed a commit to caixtong/credent-manager that referenced this issue Jun 19, 2022
Update the System.CommandLine package to 2.0.0-beta1.21216.1 to
hopefully fix some problems with dotnet-suggest registration caused by
Process::UseShellExecute differences between .NET Framework and .NET
(Core).

jonsequitur/command-line-api@ad22b69
dotnet/command-line-api#1254
git-ecosystem/git-credential-manager#505
imgbot bot pushed a commit to Jeverett3000/Git-Credential-Manager-Core that referenced this issue Nov 2, 2022
Update the System.CommandLine package to 2.0.0-beta1.21216.1 to
hopefully fix some problems with dotnet-suggest registration caused by
Process::UseShellExecute differences between .NET Framework and .NET
(Core).

jonsequitur/command-line-api@ad22b69
dotnet/command-line-api#1254
git-ecosystem#505
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth-issue An issue authenticating to a host external Relating to an external partner, team, or library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants