r-darwish / topgrade

Upgrade everything
GNU General Public License v3.0
3.36k stars 160 forks source link

GitHub CLI Extensions failed #877

Closed bgs113 closed 2 years ago

bgs113 commented 2 years ago

What did you expect to happen?

When running topgrade with the gh CLI tool, it will report success if no upgrades are needed or no extensions are installed. While the gh extension upgrade --all command reports an error code of 1 if no extensions are installed, topgrade should handle that condition and not fail the step.

What actually happened?

When running without any gh extensions installed, the upgrade process reports an error:

―― 11:05:26 - GitHub CLI Extensions ――――――――――――――――――――――――――――――――――――――――――――
X Failed upgrading extensions

Retry? (y)es/(N)o/(s)hell

In the summary, it also reports an error:

Github CLI Extensions: FAILED

Additional details

Paste the output of `topgrade -v`

❯ topgrade --only github_cli_extensions -v
 2022-03-24T16:13:40.142Z DEBUG topgrade::config > Configuration at /Users//.config/topgrade.toml
 2022-03-24T16:13:40.142Z DEBUG topgrade::config > Loaded configuration: ConfigFile { pre_commands: Some({}), post_commands: None, commands: Some({}), git_repos: None, predefined_git_repos: None, disable: None, ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, git_arguments: None, tmux_arguments: None, set_title: None, assume_yes: None, yay_arguments: None, no_retry: None, run_in_tmux: None, cleanup: None, notify_each_step: None, accept_all_windows_updates: None, bashit_branch: None, only: None, composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None }), linux: Some(Linux { yay_arguments: None, arch_package_manager: None, show_arch_news: None, trizen_arguments: None, dnf_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, enable_winget: None }), npm: Some(NPM { use_sudo: None }), vim: None, firmware: Some(Firmware { upgrade: None }), vagrant: None, flatpak: Some(Flatpak { use_sudo: None }) }
 2022-03-24T16:13:40.142Z DEBUG topgrade         > Version: 8.3.0
 2022-03-24T16:13:40.142Z DEBUG topgrade         > OS: x86_64-apple-darwin
 2022-03-24T16:13:40.142Z DEBUG topgrade         > Args { inner: ["topgrade", "--only", "github_cli_extensions", "-v"] }
 2022-03-24T16:13:40.142Z DEBUG topgrade         > Binary path: Ok("/usr/local/bin/topgrade")
 2022-03-24T16:13:40.142Z DEBUG topgrade         > Self Update: false
 2022-03-24T16:13:40.143Z DEBUG topgrade::utils  > Detected "/usr/local/bin/git" as "git"
 2022-03-24T16:13:40.143Z DEBUG topgrade::utils  > Cannot find "doas"
 2022-03-24T16:13:40.143Z DEBUG topgrade::utils  > Detected "/usr/bin/sudo" as "sudo"
 2022-03-24T16:13:40.143Z DEBUG topgrade::utils  > Detected "/usr/local/bin/pwsh" as "pwsh"
 2022-03-24T16:13:40.473Z TRACE topgrade::executor > Output of "/usr/local/bin/pwsh" "-NoProfile" "-Command" "Split-Path $profile": Output { status: ExitStatus(unix_wait_status(0)), stdout: "/Users//.config/powershell\n", stderr: "" }
 2022-03-24T16:13:40.473Z DEBUG topgrade::utils    > Path "/Users//.config/emacs" doesn't exist
 2022-03-24T16:13:40.473Z DEBUG topgrade::utils    > Path "/Users//.emacs.d" exists
 2022-03-24T16:13:40.473Z DEBUG topgrade::utils    > Path "/Users//.emacs.d/bin/doom" exists
 2022-03-24T16:13:40.473Z DEBUG topgrade::steps::git > /Users//.ideavimrc does not exists
 2022-03-24T16:13:40.473Z DEBUG topgrade::steps::git > /Users//.intellimacs does not exists
 2022-03-24T16:13:40.473Z DEBUG topgrade::steps::git > /Users//.zshrc is a file. Checking /Users/
 2022-03-24T16:13:40.473Z DEBUG topgrade::steps::git > Checking if /Users/ is a git repository
 2022-03-24T16:13:40.480Z TRACE topgrade::executor   > Output of "/usr/local/bin/git" "rev-parse" "--show-toplevel": Output { status: ExitStatus(unix_wait_status(32768)), stdout: "", stderr: "fatal: not a git repository (or any of the parent directories): .git\n" }
 2022-03-24T16:13:40.480Z DEBUG topgrade::steps::git > Checking if /Users//.config/fish is a git repository
 2022-03-24T16:13:40.486Z TRACE topgrade::executor   > Output of "/usr/local/bin/git" "rev-parse" "--show-toplevel": Output { status: ExitStatus(unix_wait_status(32768)), stdout: "", stderr: "fatal: not a git repository (or any of the parent directories): .git\n" }
 2022-03-24T16:13:40.486Z DEBUG topgrade::steps::git > /Users//Library/Application Support/openbox does not exists
 2022-03-24T16:13:40.486Z DEBUG topgrade::steps::git > /Users//Library/Application Support/bspwm does not exists
 2022-03-24T16:13:40.486Z DEBUG topgrade::steps::git > /Users//Library/Application Support/i3 does not exists
 2022-03-24T16:13:40.486Z DEBUG topgrade::steps::git > /Users//Library/Application Support/sway does not exists
 2022-03-24T16:13:40.487Z DEBUG topgrade::runner     > Step "Github CLI Extensions"
 2022-03-24T16:13:40.487Z DEBUG topgrade::utils      > Detected "/usr/local/bin/gh" as "gh"

―― 11:13:40 - GitHub CLI Extensions ――――――――――――――――――――――――――――――――――――――――――――
 2022-03-24T16:13:40.487Z DEBUG topgrade::executor   > Running "/usr/local/bin/gh" "extension" "upgrade" "--all"
X Failed upgrading extensions
 2022-03-24T16:13:40.552Z DEBUG topgrade::runner     > Step "Github CLI Extensions" failed: exit status: 1
 2022-03-24T16:13:40.552Z DEBUG topgrade::terminal   > Desktop notification: Github CLI Extensions failed

Retry? (y)es/(N)o/(s)hell

―― 11:13:43 - Summary ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Github CLI Extensions: FAILED
 2022-03-24T16:13:43.405Z DEBUG topgrade::terminal   > Desktop notification: Topgrade finished with errors
morganmay commented 2 years ago

I am also experiencing this problem. With no GitHub CLI extensions installed; gh returns an error and topgrade stops. Ideally, topgrade should only attempt to update GitHub extensions when extensions are actually installed. Something like gh extension list && gh extension upgrade --all || return 0 would fix this.

woohgit commented 2 years ago

As a quick workaround add github_cli_extensions to ~/.config/topgrade.toml's disable section.

Here is mine for reference:

disable = ["vim", "gem", 'containers', 'github_cli_extensions']
r-darwish commented 2 years ago

@morganmay thanks for clarifying. I'll submit a fix as you suggested.

rm3l commented 2 years ago

For reference, there is an issue and a PR in the GitHub CLI repo, which should make the gh CLI not exit with an error if no extension exists: https://github.com/cli/cli/issues/5348.

Update: the PR has been merged and is now available as of GitHub CLI 2.7.0