Check path for git executable before auth#4109
Merged
Conversation
There was a bug where if git was not installed then gh would do its authentication and try to configure git but would then find out that the git executable was not in PATH. Now gh checks to see if the git executable is in PATH before authenticating the user. If the git executable is in PATH the authentication continues as normal, if it is not in PATH then it prints out an error to the console: $ git executable not found in $PATH Resolves: cli#3818
mislav
approved these changes
Aug 11, 2021
Contributor
mislav
left a comment
There was a problem hiding this comment.
Thank you! Your solution was good, but it involved checking git presence at the start of the command, before it's known whether git will be needed at all. As far as I can tell, git is only needed if you chose “yes” for the step “Authenticate git with your GitHub credentials”.
I've pushed some updates so that the experience is like this now:
$ gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
unable to find git executable in PATH; please install git before retrying
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a bug where if git was not installed then gh would do its
authentication and try to configure git but would then find out that the
git executable was not in PATH.
Now gh checks to see if the git executable is in PATH before
authenticating the user. If the git executable is in PATH the
authentication continues as normal, if it is not in PATH then it prints
out an error to the console:
$ git executable not found in $PATH
Fixes #3818