Skip to content

Panic when trying to login to GitHub #6129

@BrunoCoimbra

Description

@BrunoCoimbra

Describe the bug

I get an "index out of range" error when trying to login to GitHub using HTTPS protocol.
I'm running on a M1 MacBook, and installed gh cli using Homebrew.

gh version 2.14.5 (2022-08-23)
https://github.com/cli/cli/releases/tag/v2.14.5

Steps to reproduce the behavior

  1. Type 'gh auth login'
  2. Select GitHub.com
  3. Select HTTPS
  4. See the error: panic: runtime error: index out of range [-1]

Expected vs actual behavior

Under normal circumstances I'd expect to get a link to authenticate on a web browser.

Logs

% gh auth login 
? What account do you want to log into? 
? What is your preferred protocol for Git operations? 
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
github.com/cli/cli/v2/pkg/cmd/auth/shared.Login(0x1400073f9f8)
        github.com/cli/cli/v2/pkg/cmd/auth/shared/login_flow.go:60 +0x1078
github.com/cli/cli/v2/pkg/cmd/auth/login.loginRun(0x140001b8630)
        github.com/cli/cli/v2/pkg/cmd/auth/login/login.go:175 +0x390
github.com/cli/cli/v2/pkg/cmd/auth/login.NewCmdLogin.func1(0x14000306f00?, {0x1020d9e08?, 0x0?, 0x0?})
        github.com/cli/cli/v2/pkg/cmd/auth/login/login.go:111 +0x490
github.com/spf13/cobra.(*Command).execute(0x14000306f00, {0x1020d9e08, 0x0, 0x0})
        github.com/spf13/cobra@v1.4.0/command.go:856 +0x4c4
github.com/spf13/cobra.(*Command).ExecuteC(0x140001c6c80)
        github.com/spf13/cobra@v1.4.0/command.go:974 +0x354
main.mainRun()
        github.com/cli/cli/v2/cmd/gh/main.go:214 +0xaa0
main.main()
        github.com/cli/cli/v2/cmd/gh/main.go:48 +0x1c

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority-1Affects a large population and inhibits work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions