r-darwish / topgrade

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

[bug] topgrade suddenly stops when executing flatpak step #716

Closed charitarthchugh closed 2 years ago

charitarthchugh commented 3 years ago

What did you expect to happen? ... Topgrade successfully completes flatpak step

What actually happened? ... topgrade suddenly exits while executing flatpak step

topgrade --dry-run works completely fine.

output of topgrade -v on [pastebin](https://pastebin.com/ZF1B1RZC)
charitarthchugh commented 3 years ago

I just realized the job is suspended, so I can resume it using fg [process_number] which finishes the job sucessfully

MCOfficer commented 3 years ago

Curious. What's the output when you run /usr/bin/flatpak update --user -y yourself?

charitarthchugh commented 3 years ago

@MCOfficer here it is on pastebin

r-darwish commented 3 years ago

This happened to multiple zsh users and eventually got close because they found it's a bug in ZSH. Not sure about fish, though.

charitarthchugh commented 3 years ago

Also, I just found out that when I execute on topgrade --only flatpak there are no issues at all

charitarthchugh commented 3 years ago

On version 8.0.3, with user and system flatpak packages now separated, it only happens when it reaches the system packages step.

Funky185540 commented 2 years ago

Curious, for me it happens when topgrade reaches the flatpak user package stage. System flatpaks run through fine.

I'm also using zsh, if that helps. But the bug also occurs when I run topgrade from bash...

MCOfficer commented 2 years ago

Hm. Perhaps this is related to your terminal emulator, too? For example, does it still happen if you try it in a TTY via Ctrl+Alt+F3?

Also, when you run it from bash: Is that bash that's been started from inside zsh, or is it bash in a fresh terminal emulator?

Funky185540 commented 2 years ago

Here's how to reproduce it: topgrade --only shell flatpak. After it performs the zplug updates on my PC and reaches the flatpak stage it suspends the terminal. This does not happen when I explicitly exclude the shell step.

charitarthchugh commented 2 years ago

@MCOfficer It happens in TTY too.

charitarthchugh commented 2 years ago

My bad about my earlier comment about it only happening on system packages - I meant to say user packages.

Funky185540 commented 2 years ago

If I uncomment all mentions of zplug from my .zshrc it attempts to call zplug, fails (command not found), and suspends after asking me whether I would like to retry.

charitarthchugh commented 2 years ago

The bug also occurs in zsh (when spawned from fish)

Funky185540 commented 2 years ago

And it's not the user upgrade causing the issue. If I skip the user flatpak update by uncommenting it in the sources and running from there, it still fails (but this time at the system upgrade).

charitarthchugh commented 2 years ago

@Funky185540 for zplug I think because topgrade finds the ~/.zplug folder and expects it to be initialized in your zshrc leading to command not found

MCOfficer commented 2 years ago

@Funky185540 Can you also share your verbose output? I'm curious what commands exactly are being executed for both of you.

Funky185540 commented 2 years ago

@charitarthchugh Very likely...

@MCOfficer Sure, here's the full thing:

❯ topgrade --verbose --only shell flatpak
 2021-12-16T19:09:41.688Z DEBUG topgrade::config > Configuration at /home/andi/.config/topgrade.toml
 2021-12-16T19:09:41.688Z DEBUG topgrade::config > Path ~/repos/extras/*/ expanded to /home/andi/repos/extras/*/
 2021-12-16T19:09:41.688Z DEBUG topgrade::config > Path ~/repos/shell-helpers expanded to /home/andi/repos/shell-helpers
 2021-12-16T19:09:41.688Z 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: Some(true), assume_yes: Some(true), yay_arguments: None, no_retry: None, run_in_tmux: None, cleanup: Some(true), notify_each_step: None, accept_all_windows_updates: None, bashit_branch: None, only: None, composer: Some(Composer { self_update: Some(true) }), brew: 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: Some(5), arguments: Some("--rebase --autostash"), repos: Some(["/home/andi/repos/extras/*/", "/home/andi/repos/shell-helpers"]), pull_predefined: None }), windows: None, npm: None, vim: None, firmware: Some(Firmware { upgrade: Some(true) }), vagrant: None, flatpak: Some(Flatpak { use_sudo: Some(true) }) }
 2021-12-16T19:09:41.703Z DEBUG topgrade::utils  > Detected "/usr/bin/notify-send" as "notify-send"
 2021-12-16T19:09:41.703Z DEBUG topgrade         > Version: 8.1.2
 2021-12-16T19:09:41.703Z DEBUG topgrade         > OS: x86_64-unknown-linux-gnu
 2021-12-16T19:09:41.703Z DEBUG topgrade         > Args { inner: ["topgrade", "--verbose", "--only", "shell", "flatpak"] }
 2021-12-16T19:09:41.703Z DEBUG topgrade         > Binary path: Ok("/home/andi/.cargo/bin/topgrade")
 2021-12-16T19:09:41.703Z DEBUG topgrade         > Self Update: false
 2021-12-16T19:09:41.703Z DEBUG topgrade::utils  > Detected "/usr/bin/git" as "git"
 2021-12-16T19:09:41.703Z DEBUG topgrade::utils  > Cannot find "doas"
 2021-12-16T19:09:41.703Z DEBUG topgrade::utils  > Detected "/usr/bin/sudo" as "sudo"
 2021-12-16T19:09:41.703Z DEBUG topgrade::utils  > Cannot find "pwsh"
 2021-12-16T19:09:41.703Z DEBUG topgrade::utils  > Cannot find "powershell"
 2021-12-16T19:09:41.704Z DEBUG topgrade::utils  > Path "/home/andi/.config/emacs" doesn't exist
 2021-12-16T19:09:41.704Z DEBUG topgrade::utils  > Path "/home/andi/.emacs.d" doesn't exist
 2021-12-16T19:09:41.704Z DEBUG topgrade::steps::git > /home/andi/.ideavimrc does not exists
 2021-12-16T19:09:41.704Z DEBUG topgrade::steps::git > /home/andi/.intellimacs does not exists
 2021-12-16T19:09:41.704Z DEBUG topgrade::steps::git > /home/andi/.zshrc is a file. Checking /home/andi
 2021-12-16T19:09:41.704Z DEBUG topgrade::steps::git > Checking if /home/andi is a git repository
 2021-12-16T19:09:41.708Z TRACE topgrade::executor   > Output of "/usr/bin/git" "rev-parse" "--show-toplevel": Output { status: ExitStatus(unix_wait_status(32768)), stdout: "", stderr: "fatal: not a git repository (or any parent up to mount point /)\nStopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n" }
 2021-12-16T19:09:41.709Z DEBUG topgrade::steps::git > /home/andi/.config/fish does not exists
 2021-12-16T19:09:41.709Z DEBUG topgrade::steps::git > /home/andi/.config/openbox does not exists
 2021-12-16T19:09:41.709Z DEBUG topgrade::steps::git > /home/andi/.config/bspwm does not exists
 2021-12-16T19:09:41.709Z DEBUG topgrade::steps::git > /home/andi/.config/i3 does not exists
 2021-12-16T19:09:41.709Z DEBUG topgrade::steps::git > /home/andi/.config/sway does not exists
 2021-12-16T19:09:41.709Z DEBUG topgrade::runner     > Step "zr"
 2021-12-16T19:09:41.709Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T19:09:41.709Z DEBUG topgrade::runner     > Step "antibody"
 2021-12-16T19:09:41.709Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T19:09:41.709Z DEBUG topgrade::runner     > Step "antigen"
 2021-12-16T19:09:41.709Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T19:09:41.709Z DEBUG topgrade::utils      > Path "/home/andi/.zshrc" exists
 2021-12-16T19:09:41.709Z DEBUG topgrade::runner     > Step "zplug"
 2021-12-16T19:09:41.709Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T19:09:41.709Z DEBUG topgrade::utils      > Path "/home/andi/.zshrc" exists
 2021-12-16T19:09:41.709Z DEBUG topgrade::utils      > Path "/home/andi/.zplug" exists

―― 20:09:41 - zplug ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
 2021-12-16T19:09:41.710Z DEBUG topgrade::executor   > Running "/usr/bin/zsh" "-i" "-c" "zplug update"
[zplug] Start to update 2 plugins in parallel

 ✔  Up-to-date            zsh-users/zsh-syntax-highlighting
 ✔  Up-to-date            romkatv/powerlevel10k

[zplug] Elapsed time: 1.0165 sec.
 ==> Updating finished successfully!
 2021-12-16T19:09:42.988Z DEBUG topgrade::runner     > Step "zinit"
 2021-12-16T19:09:42.988Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T19:09:42.988Z DEBUG topgrade::utils      > Path "/home/andi/.zshrc" exists
 2021-12-16T19:09:42.988Z DEBUG topgrade::runner     > Step "zim"
 2021-12-16T19:09:42.988Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T19:09:42.991Z TRACE topgrade::executor   > Output of "zsh" "-c" "[[ -n ${ZIM_HOME} ]] && print -n ${ZIM_HOME}": Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "" }
 2021-12-16T19:09:42.991Z DEBUG topgrade::runner     > Step "oh-my-zsh"
 2021-12-16T19:09:42.991Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T19:09:42.991Z DEBUG topgrade::runner     > Step "fisher"
 2021-12-16T19:09:42.991Z DEBUG topgrade::runner     > Step "bash-it"
 2021-12-16T19:09:42.991Z DEBUG topgrade::runner     > Step "oh-my-fish"
 2021-12-16T19:09:42.991Z DEBUG topgrade::runner     > Step "fish-plug"
 2021-12-16T19:09:42.991Z DEBUG topgrade::runner     > Step "Flatpak"
 2021-12-16T19:09:42.991Z DEBUG topgrade::utils      > Detected "/usr/bin/flatpak" as "flatpak"

―― 20:09:42 - Flatpak User Packages ――――――――――――――――――――――――――――――――――――――――――――
 2021-12-16T19:09:42.992Z DEBUG topgrade::executor   > Running "/usr/bin/flatpak" "update" "--user" "-y"
Looking for updates…
zsh: suspended (tty output)  topgrade --verbose --only shell flatpak
❯ kill %1
[1]  + terminated  topgrade --verbose --only shell flatpak
Funky185540 commented 2 years ago

In case you want to try yourself:

# Run this on the host
podman run --rm -it -v "$HOME/.cargo/bin/topgrade:/topgrade:Z" fedora:35
# This runs in the container
dnf install -y zsh flatpak
cd
touch .zshrc
mkdir .zplug
/topgrade --only shell flatpak
# And here it dies.
Funky185540 commented 2 years ago

This is probably as minimal as it gets, and it still fails :(

Funky185540 commented 2 years ago

Here's something. The shell receives a SIGTTOU, which apparently happens when you try to change the terminal settings while running in the background. Here's what I found so far:

If I try to strace it my shell just dies irrecoverably... But here's what I get before it kicks the bucket:

write(1, "m", 1m)                        = 1
write(1, "Retry? (y)es/(N)o/(s)hell", 25Retry? (y)es/(N)o/(s)hell) = 25
write(1, "\33[0m", 4)                   = 4
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 -opost -isig -icanon -echo ...}) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGTTOU {si_signo=SIGTTOU, si_code=SI_KERNEL} ---
--- stopped by SIGTTOU ---
MCOfficer commented 2 years ago

You might be onto something. Zsh also seems to cause funky behavior in my WSL, although not quite the same, because it wouldnt be as fun without variation:

florian@DESKTOP-IH823O4:~$ cargo run -- --only shell --verbose
 [...]
 2021-12-16T20:09:56.674Z DEBUG topgrade::steps::git > /home/florian/.config/sway does not exists
 2021-12-16T20:09:56.674Z DEBUG topgrade::runner     > Step "zr"
 2021-12-16T20:09:56.674Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T20:09:56.764Z DEBUG topgrade::runner     > Step "antibody"
 2021-12-16T20:09:56.764Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T20:09:56.855Z DEBUG topgrade::runner     > Step "antigen"
 2021-12-16T20:09:56.855Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T20:09:56.855Z DEBUG topgrade::utils      > Path "/home/florian/.zshrc" exists
 2021-12-16T20:09:56.855Z DEBUG topgrade::runner     > Step "zplug"
 2021-12-16T20:09:56.855Z DEBUG topgrade::utils      > Detected "/usr/bin/zsh" as "zsh"
 2021-12-16T20:09:56.855Z DEBUG topgrade::utils      > Path "/home/florian/.zshrc" exists
 2021-12-16T20:09:56.855Z DEBUG topgrade::utils      > Path "/home/florian/.zplug" exists

―― 21:09:56 - zplug ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
 2021-12-16T20:09:56.857Z DEBUG topgrade::executor   > Running "/usr/bin/zsh" "-i" "-c" "zplug update"
zsh:1: command not found: zplug
 2021-12-16T20:09:57.442Z DEBUG topgrade::runner     > Step "zplug" failed: exit status: 127
 2021-12-16T20:09:57.442Z DEBUG topgrade::terminal   > Desktop notification: zplug failed

Retry? (y)es/(N)o/(s)hell[src/terminal.rs:231] "Before self.term.read_key()" = "Before self.term.read_key()"

that last line is bash telling me it put the task in the background. When i pull it back up, I can give it input again:


[1]+  Stopped                 cargo run -- --only shell --verbose
florian@DESKTOP-IH823O4:/mnt/c/Users/Florian/Documents/topgrade$ fg
cargo run -- --only shell --verbose

              [PRESSED THE Q KEY RIGHT HERE]

[src/terminal.rs:232] self.term.read_key() = Ok(
    Char(
        'q',
    ),
)

This does not happen when forcing a retry dialogue in other topgrade runs, f.e. topgrade --only system (and ctrl-c the password prompt).

The two debug prints you're seeing are right here: https://github.com/r-darwish/topgrade/blob/develop/src/terminal.rs#L231

So my guess is that topgrade trying to read a key from the terminal puts it in the background due to something the zsh step does. SIGTTOU kinda fits into that? This is where my unix-fu is really hitting its limits.

MCOfficer commented 2 years ago

Did a bit of research into those other zsh user roey mentioned above, this is definitely the same issue. See #475

I guess the novelty is that this can also happen just by running a zsh update, even if the shell itself isn't actually zsh. This could be confirmed by @charitarthchugh either commenting out the zsh-related steps, or uninstalling zsh.

charitarthchugh commented 2 years ago

@MCOfficer Uninstalled zsh, works as intended

❯ topgrade --verbose --only shell flatpak
 2021-12-16T23:02:28.450Z DEBUG topgrade::config > Configuration at /home/cc/.config/topgrade.toml
 2021-12-16T23:02:28.450Z DEBUG topgrade::config > Path ~/Dev/IdeaProjects/Personal/*/*/ expanded to /home/cc/Dev/IdeaProjects/Personal/*/*/
 2021-12-16T23:02:28.450Z DEBUG topgrade::config > Path ~/Dev/GitClone/*/ expanded to /home/cc/Dev/GitClone/*/
 2021-12-16T23:02:28.450Z DEBUG topgrade::config > Path ~/Dev/Reading/*/ expanded to /home/cc/Dev/Reading/*/
 2021-12-16T23:02:28.450Z DEBUG topgrade::config > Path ~/.local/share/fonts/*/ expanded to /home/cc/.local/share/fonts/*/
 2021-12-16T23:02:28.450Z DEBUG topgrade::config > Loaded configuration: ConfigFile { pre_commands: None, post_commands: None, commands: Some({"Clean logs older than 15d": "sudo journalctl --vacuum-time=15d", "Clean old snap packages": "sudo ~/dotfiles/scripts/clean_snaps.sh", "Cleanup Package Managers": "conda clean -a -y; sudo apt autoremove --purge -y; flatpak uninstall --unused; sudo apt autoclean", "Font cache": "fc-cache -r"}), 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: Some(true), 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: Some(false) }), brew: 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: Some(true), redhat_distro_sync: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None }), git: Some(Git { max_concurrency: Some(5), arguments: Some("--rebase --autostash"), repos: Some(["/home/cc/Dev/IdeaProjects/Personal/*/*/", "/home/cc/Dev/GitClone/*/", "/home/cc/Dev/Reading/*/", "/home/cc/.local/share/fonts/*/"]), pull_predefined: None }), windows: None, npm: None, vim: None, firmware: None, vagrant: None, flatpak: None }
 2021-12-16T23:02:28.450Z DEBUG topgrade::utils  > Detected "/usr/bin/notify-send" as "notify-send"
 2021-12-16T23:02:28.450Z DEBUG topgrade         > Version: 8.1.1
 2021-12-16T23:02:28.450Z DEBUG topgrade         > OS: x86_64-unknown-linux-gnu
 2021-12-16T23:02:28.450Z DEBUG topgrade         > Args { inner: ["topgrade", "--verbose", "--only", "shell", "flatpak"] }
 2021-12-16T23:02:28.450Z DEBUG topgrade         > Binary path: Ok("/home/cc/.cargo/bin/topgrade")
 2021-12-16T23:02:28.450Z DEBUG topgrade         > Self Update: false
 2021-12-16T23:02:28.451Z DEBUG topgrade::utils  > Detected "/usr/bin/git" as "git"
 2021-12-16T23:02:28.451Z DEBUG topgrade::utils  > Cannot find "doas"
 2021-12-16T23:02:28.451Z DEBUG topgrade::utils  > Detected "/usr/bin/sudo" as "sudo"
 2021-12-16T23:02:28.451Z DEBUG topgrade::utils  > Cannot find "pwsh"
 2021-12-16T23:02:28.451Z DEBUG topgrade::utils  > Cannot find "powershell"
 2021-12-16T23:02:28.451Z DEBUG topgrade::utils  > Path "/home/cc/.config/emacs" doesn't exist
 2021-12-16T23:02:28.451Z DEBUG topgrade::utils  > Path "/home/cc/.emacs.d" doesn't exist
 2021-12-16T23:02:28.451Z DEBUG topgrade::steps::git > /home/cc/.ideavimrc does not exists
 2021-12-16T23:02:28.451Z DEBUG topgrade::steps::git > /home/cc/.intellimacs does not exists
 2021-12-16T23:02:28.451Z DEBUG topgrade::steps::git > /home/cc/dotfiles/.zshrc is a file. Checking /home/cc/dotfiles
 2021-12-16T23:02:28.451Z DEBUG topgrade::steps::git > Checking if /home/cc/dotfiles is a git repository
 2021-12-16T23:02:28.451Z TRACE topgrade::executor   > Output of "/usr/bin/git" "rev-parse" "--show-toplevel": Output { status: ExitStatus(unix_wait_status(0)), stdout: "/home/cc/dotfiles\n", stderr: "" }
 2021-12-16T23:02:28.451Z DEBUG topgrade::steps::git > Checking if /home/cc/.config/fish is a git repository
 2021-12-16T23:02:28.452Z TRACE topgrade::executor   > Output of "/usr/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" }
 2021-12-16T23:02:28.452Z DEBUG topgrade::steps::git > /home/cc/.config/openbox does not exists
 2021-12-16T23:02:28.452Z DEBUG topgrade::steps::git > /home/cc/.config/bspwm does not exists
 2021-12-16T23:02:28.452Z DEBUG topgrade::steps::git > /home/cc/.config/i3 does not exists
 2021-12-16T23:02:28.452Z DEBUG topgrade::steps::git > /home/cc/.config/sway does not exists
 2021-12-16T23:02:28.452Z DEBUG topgrade::runner     > Step "zr"
 2021-12-16T23:02:28.452Z DEBUG topgrade::runner     > Step "antibody"
 2021-12-16T23:02:28.452Z DEBUG topgrade::runner     > Step "antigen"
 2021-12-16T23:02:28.452Z DEBUG topgrade::runner     > Step "zplug"
 2021-12-16T23:02:28.452Z DEBUG topgrade::runner     > Step "zinit"
 2021-12-16T23:02:28.452Z DEBUG topgrade::runner     > Step "zim"
 2021-12-16T23:02:28.452Z DEBUG topgrade::runner     > Step "oh-my-zsh"
 2021-12-16T23:02:28.452Z DEBUG topgrade::runner     > Step "fisher"
 2021-12-16T23:02:28.452Z DEBUG topgrade::utils      > Detected "/usr/bin/fish" as "fish"
 2021-12-16T23:02:28.452Z DEBUG topgrade::utils      > Path "/home/cc/.config/fish/functions/fisher.fish" exists

―― 18:02:28 - Fisher ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
 2021-12-16T23:02:28.452Z DEBUG topgrade::executor   > Running "/usr/bin/fish" "-c" "fisher update"
fisher update version 4.3.0
Fetching https://codeload.github.com/laughedelic/brew-completions/tar.gz/HEAD
Fetching https://codeload.github.com/jorgebucaran/autopair.fish/tar.gz/HEAD
Fetching https://codeload.github.com/gazorby/fish-exa/tar.gz/HEAD
Fetching https://codeload.github.com/joseluisq/gitnow/tar.gz/2.5.1
Fetching https://codeload.github.com/wfxr/forgit/tar.gz/HEAD
Fetching https://codeload.github.com/brgmnn/fish-docker-compose/tar.gz/HEAD
Fetching https://codeload.github.com/jorgebucaran/gitio.fish/tar.gz/HEAD
Fetching https://codeload.github.com/jethrokuan/z/tar.gz/HEAD
Fetching https://codeload.github.com/jorgebucaran/bax.fish/tar.gz/HEAD
Fetching https://codeload.github.com/oh-my-fish/plugin-bang-bang/tar.gz/HEAD
Fetching https://codeload.github.com/gazorby/fish-abbreviation-tips/tar.gz/HEAD
Fetching https://codeload.github.com/jorgebucaran/nvm.fish/tar.gz/HEAD
Fetching https://codeload.github.com/franciscolourenco/done/tar.gz/HEAD
Fetching https://codeload.github.com/jhillyerd/plugin-git/tar.gz/HEAD
Fetching https://codeload.github.com/PatrickF1/fzf.fish/tar.gz/HEAD
Fetching https://codeload.github.com/jorgebucaran/fisher/tar.gz/HEAD
Installing jethrokuan/z
           /home/cc/.config/fish/functions/__z.fish
           /home/cc/.config/fish/functions/__z_add.fish
           /home/cc/.config/fish/functions/__z_clean.fish
           /home/cc/.config/fish/functions/__z_complete.fish
           /home/cc/.config/fish/conf.d/z.fish
Installing joseluisq/gitnow@2.5.1
           /home/cc/.config/fish/functions/__gitnow_config_file.fish
           /home/cc/.config/fish/functions/__gitnow_functions.fish
           /home/cc/.config/fish/functions/__gitnow_manual.fish
           /home/cc/.config/fish/conf.d/gitnow.fish
           /home/cc/.config/fish/conf.d/gitnow_config.fish
           /home/cc/.config/fish/completions/__gitnow_completions.fish
Installing jorgebucaran/bax.fish
           /home/cc/.config/fish/functions/replay.fish
           /home/cc/.config/fish/completions/replay.fish
Installing jorgebucaran/gitio.fish
           /home/cc/.config/fish/functions/gitio.fish
           /home/cc/.config/fish/completions/gitio.fish
Installing PatrickF1/fzf.fish
           /home/cc/.config/fish/functions/_fzf_configure_bindings_help.fish
           /home/cc/.config/fish/functions/_fzf_extract_var_info.fish
           /home/cc/.config/fish/functions/_fzf_preview_file.fish
           /home/cc/.config/fish/functions/_fzf_report_file_type.fish
           /home/cc/.config/fish/functions/_fzf_search_directory.fish
           /home/cc/.config/fish/functions/_fzf_search_git_log.fish
           /home/cc/.config/fish/functions/_fzf_search_git_status.fish
           /home/cc/.config/fish/functions/_fzf_search_history.fish
           /home/cc/.config/fish/functions/_fzf_search_variables.fish
           /home/cc/.config/fish/functions/_fzf_wrapper.fish
           /home/cc/.config/fish/functions/fzf_configure_bindings.fish
           /home/cc/.config/fish/conf.d/fzf.fish
           /home/cc/.config/fish/completions/fzf_configure_bindings.fish
Installing franciscolourenco/done
           /home/cc/.config/fish/conf.d/done.fish
Installing jorgebucaran/autopair.fish
           /home/cc/.config/fish/functions/_autopair_backspace.fish
           /home/cc/.config/fish/functions/_autopair_insert_left.fish
           /home/cc/.config/fish/functions/_autopair_insert_right.fish
           /home/cc/.config/fish/functions/_autopair_insert_same.fish
           /home/cc/.config/fish/functions/_autopair_tab.fish
           /home/cc/.config/fish/conf.d/autopair.fish
Installing laughedelic/brew-completions
           /home/cc/.config/fish/completions/brew.fish
Installing jorgebucaran/nvm.fish
           /home/cc/.config/fish/functions/_nvm_index_update.fish
           /home/cc/.config/fish/functions/_nvm_list.fish
           /home/cc/.config/fish/functions/_nvm_version_activate.fish
           /home/cc/.config/fish/functions/_nvm_version_deactivate.fish
           /home/cc/.config/fish/functions/nvm.fish
           /home/cc/.config/fish/conf.d/nvm.fish
           /home/cc/.config/fish/completions/nvm.fish
Installing gazorby/fish-abbreviation-tips
           /home/cc/.config/fish/functions/__abbr_tips_bind_newline.fish
           /home/cc/.config/fish/functions/__abbr_tips_bind_space.fish
           /home/cc/.config/fish/functions/__abbr_tips_init.fish
           /home/cc/.config/fish/conf.d/abbr_tips.fish
Installing brgmnn/fish-docker-compose
           /home/cc/.config/fish/completions/docker-compose.fish
Installing gazorby/fish-exa
           /home/cc/.config/fish/functions/exa_git.fish
           /home/cc/.config/fish/conf.d/fish-exa.fish
Installing oh-my-fish/plugin-bang-bang
           /home/cc/.config/fish/functions/__history_previous_command.fish
           /home/cc/.config/fish/functions/__history_previous_command_arguments.fish
           /home/cc/.config/fish/conf.d/plugin-bang-bang.fish
Installing wfxr/forgit
           /home/cc/.config/fish/conf.d/forgit.plugin.fish
Installing jhillyerd/plugin-git
           /home/cc/.config/fish/functions/__git.branch_has_wip.fish
           /home/cc/.config/fish/functions/__git.current_branch.fish
           /home/cc/.config/fish/functions/__git.default_branch.fish
           /home/cc/.config/fish/functions/__git.destroy.fish
           /home/cc/.config/fish/functions/__git.init.fish
           /home/cc/.config/fish/functions/__git.reset.fish
           /home/cc/.config/fish/functions/gbage.fish
           /home/cc/.config/fish/functions/gbda.fish
           /home/cc/.config/fish/functions/gdt.fish
           /home/cc/.config/fish/functions/gdv.fish
           /home/cc/.config/fish/functions/ggl.fish
           /home/cc/.config/fish/functions/ggp.fish
           /home/cc/.config/fish/functions/ggpnp.fish
           /home/cc/.config/fish/functions/ggsup.fish
           /home/cc/.config/fish/functions/ggu.fish
           /home/cc/.config/fish/functions/gignored.fish
           /home/cc/.config/fish/functions/glp.fish
           /home/cc/.config/fish/functions/gpoat.fish
           /home/cc/.config/fish/functions/grename.fish
           /home/cc/.config/fish/functions/grt.fish
           /home/cc/.config/fish/functions/gtl.fish
           /home/cc/.config/fish/functions/gunwip.fish
           /home/cc/.config/fish/functions/gwip.fish
           /home/cc/.config/fish/conf.d/git.fish
Installing jorgebucaran/fisher
           /home/cc/.config/fish/functions/fisher.fish
           /home/cc/.config/fish/completions/fisher.fish
Updated 16 plugin/s
 2021-12-16T23:02:30.092Z DEBUG topgrade::runner     > Step "bash-it"
 2021-12-16T23:02:30.092Z DEBUG topgrade::runner     > Step "oh-my-fish"
 2021-12-16T23:02:30.092Z DEBUG topgrade::utils      > Detected "/usr/bin/fish" as "fish"
 2021-12-16T23:02:30.092Z DEBUG topgrade::runner     > Step "fish-plug"
 2021-12-16T23:02:30.092Z DEBUG topgrade::utils      > Detected "/usr/bin/fish" as "fish"
 2021-12-16T23:02:30.092Z DEBUG topgrade::runner     > Step "Flatpak"
 2021-12-16T23:02:30.092Z DEBUG topgrade::utils      > Detected "/usr/bin/flatpak" as "flatpak"

―― 18:02:30 - Flatpak User Packages ――――――――――――――――――――――――――――――――――――――――――――
 2021-12-16T23:02:30.092Z DEBUG topgrade::executor   > Running "/usr/bin/flatpak" "update" "--user" "-y"
Looking for updates…
Nothing to do.

―― 18:02:30 - Flatpak System Packages ――――――――――――――――――――――――――――――――――――――――――
 2021-12-16T23:02:30.108Z DEBUG topgrade::executor   > Running "/usr/bin/flatpak" "update" "--system" "-y"
Looking for updates…
Nothing to do.

―― 18:02:30 - Summary ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
zr: SKIPPED: Cannot find "zsh" in PATH
antibody: SKIPPED: Cannot find "zsh" in PATH
antigen: SKIPPED: Cannot find "zsh" in PATH
zplug: SKIPPED: Cannot find "zsh" in PATH
zinit: SKIPPED: Cannot find "zsh" in PATH
zim: SKIPPED: Cannot find "zsh" in PATH
oh-my-zsh: SKIPPED: Cannot find "zsh" in PATH
fisher: OK
bash-it: SKIPPED: Path "/home/cc/.bash_it" doesn't exist
oh-my-fish: SKIPPED: Path "/home/cc/.local/share/omf/pkg/omf/functions/omf.fish" doesn't exist
fish-plug: SKIPPED: Path "/home/cc/.local/share/fish/plug/kidonng/fish-plug/functions/plug.fish" doesn't exist
Flatpak: OK
 2021-12-16T23:02:30.366Z DEBUG topgrade::terminal   > Desktop notification: Topgrade finished successfully
Funky185540 commented 2 years ago

So in fact we don't even need topgrade to achieve this behavior. Just put this in a shell script, like test.zsh:

#!/usr/bin/zsh

zsh -i -c "zplug update"
/usr/bin/flatpak update --user -y

And run it. The flatpak update will be suspended...

Edit:
Interestingly if we insert stty -tostop between the two commands in the script, the flatpak call will suspend even before having produced any output (i.e. the line "Looking for updates…" won't appear). But apart from that the behavior seems to be equivalent.

Edit 2:
I guess if someone were to work through the whole GNU docs they may find a solution in there. But it's quite the rabbit hole... If you have GNUs info, you can check it out yourself: info libc sigttou

Funky185540 commented 2 years ago

The issue seems to be in what flatpak does before outputting "Looking for updates..." to the shell. If you run flatpak with "-vv" it will print something else before "Looking for updates..." to the shell and the step runs through. If we substitute the "-y" in flatpak with "--noninteractive" it works. The only difference is then that it doesn't output "Looking for updates..." and possibly the output when it found updates is different, too. But I can't currently test that.

TL;DR: If we substitute -y with --noninteractive in the flatpak step, it will magically work.

Funky185540 commented 2 years ago

If I build both topgrade and flatpak from source, it works... Could this be related to downstream packaging? I'm running Fedora 34. I'm preparing a container to run all of the steps (Install deps, get flatpak, zplug and topgrade, install everything...). I can share it if someone else wants to have a look at it.

Funky185540 commented 2 years ago

The problem is triggered in flatpak by the method flatpak_disable_raw_mode in line 8442 of common/flatpak-utils.c, which is being called as part of the update transaction when run from the CLI.

void
flatpak_disable_raw_mode (void)
{
  struct termios raw;

  tcgetattr (STDIN_FILENO, &raw);

  raw.c_lflag |= (ECHO | ICANON);

  tcsetattr (STDIN_FILENO, TCSAFLUSH, &raw);
}

The call to tcsetattr changes the ttys settings, causing the suspend. This looks like a problem best fixed in zsh to me... Any thoughts?

Edit: Btw, I think this also explains your comment @MCOfficer:

So my guess is that topgrade trying to read a key from the terminal puts it in the background due to something the zsh step does. SIGTTOU kinda fits into that? This is where my unix-fu is really hitting its limits.

Funky185540 commented 2 years ago

@charitarthchugh and @MCOfficer , what does your .zshrc look like? Are you using plugin managers or plugins? I cannot reproduce this behavior in a vanilla zsh.

MCOfficer commented 2 years ago

Default installation on Debian WSL. My .zshrc is empty. I get similar behavior to you, not quite the same. zsh 5.8-3ubuntu1

Funky185540 commented 2 years ago

Default installation on Debian WSL. My .zshrc is empty. I get similar behavior to you, not quite the same. zsh 5.8-3ubuntu1

Okay, interesting. Then why does it attempt to run zplug in your output above?

MCOfficer commented 2 years ago

Default installation on Debian WSL. My .zshrc is empty. I get similar behavior to you, not quite the same. zsh 5.8-3ubuntu1

Okay, interesting. Then why does it attempt to run zplug in your output above?

Because .zplug exists, but i seem to remember that i created that for testing. It's been a while though.

Funky185540 commented 2 years ago

Could you please create a script somewhere with this content:

#!/usr/bin/zsh

/usr/bin/zsh -i -c "echo foo"
stty icanon
echo "bar"

And execute that from your shell? The shell you run it from doesn't matter. This suffices to reproduce the suspension on my machine. Note that this is only because I'm invoking zplug load in my .zshrc as soon as I comment that out, it doesn't suspend. So in theory this shouldn't affect your shell...

charitarthchugh commented 2 years ago

@charitarthchugh and @MCOfficer , what does your .zshrc look like? Are you using plugin managers or plugins? I cannot reproduce this behavior in a vanilla zsh.

My zshrc looks like this: https://github.com/charitarthchugh/dotfiles/blob/master/.zshrc

charitarthchugh commented 2 years ago

@Funky185540 The script that you wrote does cause a suspension when zplug is also loaded. Commenting out my zplug load does fix the issue.

MCOfficer commented 2 years ago

Could you please create a script somewhere with this content:

#!/usr/bin/zsh

/usr/bin/zsh -i -c "echo foo"
stty icanon
echo "bar"

And execute that from your shell? The shell you run it from doesn't matter. This suffices to reproduce the suspension on my machine. Note that this is only because I'm invoking zplug load in my .zshrc as soon as I comment that out, it doesn't suspend. So in theory this shouldn't affect your shell...

No suspension here, but i would advise you to treat my setup as a weird outlier - between my jerry-rigged zsh, WSL and the terminal emulator used to run WSL, there are a dozen things that could skew my result. @charitarthchugh's is where it's at.

Funky185540 commented 2 years ago

My zshrc looks like this: https://github.com/charitarthchugh/dotfiles/blob/master/.zshrc

If you're brave you can edit ~/.zplug/base/core/load.zsh and comment out setopt nomonitor in line 3. Once you do that, the script and henceforth topgrade, too, should run without issues.

Edit: But so far I haven't found a way to "negate" this in any other way. Simply executing setopt monitor or likewise unsetopt nomonitor do not achieve the desired result...

Funky185540 commented 2 years ago

So after my ''research'' so far, here's my personal wrapup of the situation:

Also, zplug hasn't received any attention in over 2 years now so it's unlikely that a bug report to the maintainer will have a significant effect. :/ I have now switched to sheldon instead, as it perfectly replaces zplug for my personal needs. Maybe this will help someone.