Skip to content

gh <anything> hangs after completion for ~30 seconds #6867

Closed

Description

@jbrwilkinson

Describe the bug

When I issue any command at all, even gh --help and gh --version, the command line waits a long time (~30 seconds) before returning control to the user.

Steps to reproduce the behaviour

on macOS

  1. brew upgrade gh
  2. gh --version

..waits ~30 seconds before returning control.

Expected vs actual behaviour

It should execute the command, printing the output and any errors, then stop without waiting.

Logs

Paste the activity from your command line. Redact if needed.

% env | grep PAGER
% echo $SHELL
/bin/zsh
% system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 12.6.2 (21G320)
      Kernel Version: Darwin 21.6.0
.....snipped....
% time gh --version
gh version 2.21.2 (2023-01-03)
https://github.com/cli/cli/releases/tag/v2.21.2
gh --version  0.05s user 0.01s system 0% cpu 30.057 total

Activity

  1. changed the title [-]gh <anything> does not finish; have to CTRL+C[/-] [+]gh <anything> hangs after completion for ~30 seconds; have to CTRL+C[/+] on Jan 16, 2023
  2. changed the title [-]gh <anything> hangs after completion for ~30 seconds; have to CTRL+C[/-] [+]gh <anything> hangs after completion for ~30 seconds[/+] on Jan 16, 2023
  3. jbrwilkinson commented on Jan 16, 2023

    @jbrwilkinson
    Author
    % time gh --help
    Work seamlessly with GitHub from the command line.
    ...
      Use 'gh <command> <subcommand> --help' for more information about a command.
      Read the manual at https://cli.github.com/manual
    
    gh --help  0.05s user 0.02s system 0% cpu 30.058 total
  4. jbrwilkinson commented on Jan 16, 2023

    @jbrwilkinson
    Author
    env http_proxy=<internet Proxy> time gh --version
    gh version 2.21.2 (2023-01-03)
    https://github.com/cli/cli/releases/tag/v2.21.2
            0.05 real         0.04 user         0.01 sys

    Looks like gh is trying to hit the internet even for --version

  5. mislav commented on Jan 17, 2023

    @mislav
    Contributor

    Looks like gh is trying to hit the internet even for --version

    Yes, to check for newer versions of itself. It does that only once per 24 hours.

    To disable this behavior, set export GH_NO_UPDATE_NOTIFIER=true in your environment. Note, however, that most other gh commands need the network to make API requests.

    Closing since this is a problem with proxy networking.

  6. jbrwilkinson commented on Jan 17, 2023

    @jbrwilkinson
    Author

    @mislav Many GitHub Enterprise users work in an environment where access to the internet isn't a given; when tools need updating, they'd run the update mechanism specifically, e.g. apt-get update or similar. Normal (non-update) workflow would not be expected to reach out to the internet.

    Could the decision to check for updates be gated on the remote url containing GitHub.com?

  7. mislav commented on Jan 17, 2023

    @mislav
    Contributor

    We'd want users to stay up to date even if they're using gh to exclusively communicate with non-GitHub.com hosts, so to pay attention to git remotes would be a no go in my view. However, I do understand that some people prefer to use their package manager (like apt-get) to check for updates instead of the software to "phone home" to try to check itself.

    Right now, the only ways to prevent gh from "phoning home" is to either:

    1. Set the environment GH_NO_UPDATE_NOTIFIER variable;
    2. Compile gh from source.

    Do you think that our official deb & RPM packaged-gh should never contact github.com server by default?

  8. reopened this on Jan 17, 2023
  9. added
    discussFeature changes that require discussion primarily among the GitHub CLI team
    and removed
    bugSomething isn't working
    on Jan 17, 2023
  10. added
    enhancementa request to improve CLI
    and removed
    discussFeature changes that require discussion primarily among the GitHub CLI team
    on Jan 30, 2023
  11. mislav commented on Jan 30, 2023

    @mislav
    Contributor

    We've talked about this and decided:

    1. We should disable the update checker in our official Debian and RPM packages;
    2. We should cancel the update checker goroutine if the main command finishes beforehand, so that the checker cannot ever delay the exit status of the command;
    3. We could consider dropping the entire update checker functionality altogether. It was primarily added because we found out that Homebrew users were often running an extremely out-of-date version. https://github.com/Homebrew/homebrew-core/blob/6e18df78b5e501501106a8f2477d4ee75e5c2dfe/Formula/gh.rb#L30
  12. jbrwilkinson commented on Feb 24, 2023

    @jbrwilkinson
    Author

    Amazing, @mislav, thanks for coming through with this, much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions