gh <anything> hangs after completion for ~30 seconds #6867
Copy link
Copy link
Closed
Labels
enhancementa request to improve CLIa request to improve CLI
Description
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
brew upgrade ghgh --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 totalReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementa request to improve CLIa request to improve CLI
Activity
[-]gh <anything> does not finish; have to CTRL+C[/-][+]gh <anything> hangs after completion for ~30 seconds; have to CTRL+C[/+][-]gh <anything> hangs after completion for ~30 seconds; have to CTRL+C[/-][+]gh <anything> hangs after completion for ~30 seconds[/+]jbrwilkinson commentedon Jan 16, 2023
jbrwilkinson commentedon Jan 16, 2023
Looks like
ghis trying to hit the internet even for--versionmislav commentedon Jan 17, 2023
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=truein 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.
jbrwilkinson commentedon Jan 17, 2023
@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 updateor 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?mislav commentedon Jan 17, 2023
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:
GH_NO_UPDATE_NOTIFIERvariable;Do you think that our official deb & RPM packaged-gh should never contact
github.comserver by default?mislav commentedon Jan 30, 2023
We've talked about this and decided:
jbrwilkinson commentedon Feb 24, 2023
Amazing, @mislav, thanks for coming through with this, much appreciated.