microsoft / Git-Credential-Manager-for-Windows

Secure Git credential storage for Windows with support for Visual Studio Team Services, GitHub, and Bitbucket multi-factor authentication.
Other
2.86k stars 590 forks source link

Installer doesn't detect existing portable Git installations #121

Closed prasannavl closed 8 years ago

prasannavl commented 8 years ago

I use a portable installation of Git, which is in the path. The installer should ideally detect them and and offer to skip Git installation by itself. However, the installer locks on to the installation by disabling the option to skip it. This shouldn't be the ideal behavior.

Also, the lack of the zip with the current release, as filed here https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/120 elevates this issue.

whoisj commented 8 years ago

@prasannavl you're not the first person to request the .zip file be part of future releases. I'll make sure that they get included starting with the next release. The archive was removed due to confusion (vs the setup.exe) it was causing with many users.

The GCM installer should find any git.exe that is on your %PATH%. Are you referring to %PATH% or $path (bash only)?

prasannavl commented 8 years ago

I have git in my path.

PS C:\Users\PVL> $env:Path -split ";" | Out-String -Stream | sls git

D:\Apps\DevTools\Git\bin
D:\Apps\DevTools\Git\usr\bin

But the installer doesn't detect it. But my hunch is that it's because it searches for "git.exe", but git also allows the option to use the "git.cmd", so that it doesn't pollute the environment. Perhaps that the problem, the installer was looking for "git.exe" instead. Could you please add "git.cmd" to the checks as well?

whoisj commented 8 years ago

The GCM installer uses replicated where logic. (ref)

It should look for any extensions your environment claims to understand.

prasannavl commented 8 years ago

@whoisj, I'm not sure if there was a misunderstanding, but on my first post, I was referring to setup program that installs Git, and not the deploy command.

Does the installer use the same set of source as Where as well?

However, I quickly tried the deploy command, I ended up with the following. Seems like it doesn't detect the installation as well. A bit caught up at the moment, but will debug it at the end of the day and figure out why its happening since the on a glance the Where class seems to be quite straightforward and it shouldn't be happening.

Program::Deploy
Installer::DeployConsole

Looking for Git installation(s)...
Where::Git
Where::App
   0 Git installation(s) found.

Deploying from 'D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\bin\Debug' to 'C:\ProgramData\Git'.
Installer::CopyFiles
   copy 'D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\bin\Debug' to 'C:\ProgramData\Git'.
   copy 'D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\bin\Debug' to 'C:\ProgramData\Git'.
   copy 'D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\bin\Debug' to 'C:\ProgramData\Git'.
   copy 'D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\bin\Debug' to 'C:\ProgramData\Git'.
   copy 'D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\bin\Debug' to 'C:\ProgramData\Git'.
  Microsoft.Alm.Authentication.dll
  Microsoft.Alm.Git.dll
  Microsoft.IdentityModel.Clients.ActiveDirectory.dll
  Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll
  git-credential-manager.exe
        5 file(s) copied
Installer::SetGitConfig
   action = Set.
Fatal: ArgumentOutOfRangeException encountered.
Fatal: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Microsoft.Alm.CredentialHelper.Installer.SetGitConfig(List`1 installations, GitConfigAction action, Type type, Type& updated) in D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\Installer.cs:line 477
   at Microsoft.Alm.CredentialHelper.Installer.DeployConsole() in D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\Installer.cs:line 220
   at Microsoft.Alm.CredentialHelper.Program.Deploy() in D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\Program.cs:line 505
   at Microsoft.Alm.CredentialHelper.Program.Main(String[] args) in D:\Workspace\Repos\Git-Credential-Manager-for-Windows\Cli-CredentialHelper\Program.cs:line 143
prasannavl commented 8 years ago

Fix for the above ArgumentOutOfRangeException: https://github.com/Microsoft/Git-Credential-Manager-for-Windows/pull/124

prasannavl commented 8 years ago

Ok. So, the problem lies in the fact that when the validity is checked, the found path actually contains, the Git.EXE as a part of the path. So, the following path are checked for inclusive of a directory called "Git.EXE" which doesn't exist.

Below is the output of a version that traces, the GitInstallation.IsValid method. The points of interest are the first three sets of the Path, Libexec, and Git.

Where::Git
Where::App
Path: D:\Apps\DevTools\Git\bin\Git.EXE
Libexec: D:\Apps\DevTools\Git\bin\Git.EXE\mingw64\libexec\git-core
Git: D:\Apps\DevTools\Git\bin\Git.EXE\cmd\git.exe
Path: D:\Apps\DevTools\Git\bin\Git.EXE
Libexec: D:\Apps\DevTools\Git\bin\Git.EXE\mingw32\libexec\git-core
Git: D:\Apps\DevTools\Git\bin\Git.EXE\cmd\git.exe
Path: D:\Apps\DevTools\Git\bin\Git.EXE
Libexec: D:\Apps\DevTools\Git\bin\Git.EXE\libexec\git-core\
Git: D:\Apps\DevTools\Git\bin\Git.EXE\cmd\git.exe
Path: C:\Program Files\Git
Libexec: C:\Program Files\Git\mingw64\libexec\git-core
Git: C:\Program Files\Git\cmd\git.exe
Path: C:\Program Files (x86)\Git
Libexec: C:\Program Files (x86)\Git\mingw32\libexec\git-core
Git: C:\Program Files (x86)\Git\cmd\git.exe
Path: C:\Program Files (x86)\Git
Libexec: C:\Program Files (x86)\Git\libexec\git-core\
Git: C:\Program Files (x86)\Git\cmd\git.exe
Path: C:\ProgramData\Git
Libexec: C:\ProgramData\Git\mingw64\libexec\git-core
Git: C:\ProgramData\Git\cmd\git.exe
Path: C:\ProgramData\Git
Libexec: C:\ProgramData\Git\mingw32\libexec\git-core
Git: C:\ProgramData\Git\cmd\git.exe
Path: C:\ProgramData\Git
Libexec: C:\ProgramData\Git\libexec\git-core\
Git: C:\ProgramData\Git\cmd\git.exe
Path: C:\Users\PVL\AppData\Local\Git
Libexec: C:\Users\PVL\AppData\Local\Git\mingw64\libexec\git-core
Git: C:\Users\PVL\AppData\Local\Git\cmd\git.exe
Path: C:\Users\PVL\AppData\Local\Git
Libexec: C:\Users\PVL\AppData\Local\Git\mingw32\libexec\git-core
Git: C:\Users\PVL\AppData\Local\Git\cmd\git.exe
Path: C:\Users\PVL\AppData\Local\Git
Libexec: C:\Users\PVL\AppData\Local\Git\libexec\git-core\
Git: C:\Users\PVL\AppData\Local\Git\cmd\git.exe
Path: C:\Users\PVL\AppData\Roaming\Git
Libexec: C:\Users\PVL\AppData\Roaming\Git\mingw64\libexec\git-core
Git: C:\Users\PVL\AppData\Roaming\Git\cmd\git.exe
Path: C:\Users\PVL\AppData\Roaming\Git
Libexec: C:\Users\PVL\AppData\Roaming\Git\mingw32\libexec\git-core
Git: C:\Users\PVL\AppData\Roaming\Git\cmd\git.exe
Path: C:\Users\PVL\AppData\Roaming\Git
Libexec: C:\Users\PVL\AppData\Roaming\Git\libexec\git-core\
Git: C:\Users\PVL\AppData\Roaming\Git\cmd\git.exe
   0 Git installation(s) found.
   No Git installations detected to update.
prasannavl commented 8 years ago

Pull request for the fix: https://github.com/Microsoft/Git-Credential-Manager-for-Windows/pull/125