topgrade-rs / topgrade

Upgrade all the things
GNU General Public License v3.0
2.07k stars 141 forks source link

Topgrade tries to update snap in WSL, even when disabling "snap" under Windows #876

Open Mazwak opened 4 months ago

Mazwak commented 4 months ago

Erroneous Behavior

If I disable "snap" from command-line or configuration file on Windows, topgrade still try to update snap inside WSL.

Expected Behavior

topgrade should not try to update "snap".

Steps to reproduce

On windows, with an Ubuntu WSL, just run "topgrade --disable snap"

Possible Cause (Optional)

topgrade win launches topgrade wsl without the same options.

Did you run topgrade through Remote Execution

Configuration file (Optional)

disable = ["snap", "winget"]

Additional Details

Verbose Output (topgrade -v)

Snap errors are another problem that comes from proxy.

topgrade -v --only wsl --disable snap
DEBUG Configuration at C:\Users\redacted\AppData\Roaming\topgrade.toml
DEBUG Loaded configuration: ConfigFile { include: Some(Include { paths: None }), misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: Some([Wsl, Winget]), ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, cleanup: None, notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({}), post_commands: Some({}), commands: Some({}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: None, pipupgrade_arguments: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None, greedy_latest: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: None, windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: Some(Yarn { use_sudo: None }), vim: Some(Vim { force_plug_update: None }), firmware: Some(Firmware { upgrade: None }), vagrant: Some(Vagrant { directories: None, power_on: None, always_suspend: None }), flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }), lensfun: None }
DEBUG Version: 15.0.0
DEBUG OS: x86_64-pc-windows-msvc
DEBUG Args { inner: ["C:\\Users\\redacted\\.cargo\\bin\\topgrade.exe", "-v", "--only", "wsl", "--disable", "snap"] }
DEBUG Binary path: Ok("C:\\Users\\redacted\\.cargo\\bin\\topgrade.exe")
DEBUG self-update Feature Enabled: true
DEBUG Configuration: Config { opt: CommandLineArgs { edit_config: false, show_config_reference: false, run_in_tmux: false, cleanup: false, dry_run: false, no_retry: false, disable: [Snap], only: [Wsl], custom_commands: [], env: [], verbose: true, keep_at_end: false, skip_notify: false, yes: None, disable_predefined_git_repos: false, config: None, remote_host_limit: None, show_skipped: false, log_filter: "warn", gen_completion: None, gen_manpage: false, no_self_update: false }, config_file: ConfigFile { include: Some(Include { paths: None }), misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: Some([Wsl, Winget]), ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, cleanup: None, notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({}), post_commands: Some({}), commands: Some({}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: None, pipupgrade_arguments: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None, greedy_latest: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: None, windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: Some(Yarn { use_sudo: None }), vim: Some(Vim { force_plug_update: None }), firmware: Some(Firmware { upgrade: None }), vagrant: Some(Vagrant { directories: None, power_on: None, always_suspend: None }), flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }), lensfun: None }, allowed_steps: [Wsl] }
DEBUG Detected "C:\\Program Files\\PowerShell\\7\\pwsh.exe" as "pwsh"
DEBUG Executing command `C:\Program Files\PowerShell\7\pwsh.exe -NoProfile -Command 'Split-Path $profile'`
DEBUG Path "C:\\Users\\redacted\\Documents\\PowerShell" exists
DEBUG Path "C:\\Users\\redacted\\AppData\\Roaming\\.emacs.d" doesn't exist
DEBUG Cannot find "doas"
DEBUG Cannot find "sudo"
DEBUG Cannot find "gsudo"
DEBUG Cannot find "pkexec"
DEBUG Cannot find "please"
DEBUG Step "WSL"
DEBUG Detected "C:\\WINDOWS\\system32\\wsl.exe" as "wsl"
DEBUG Detected "C:\\WINDOWS\\system32\\wsl.exe" as "wsl"
DEBUG Executing command `C:\WINDOWS\system32\wsl.exe --list -q`
DEBUG WSL distributions: ["Ubuntu-22.04", ""]
DEBUG Executing command `C:\WINDOWS\system32\wsl.exe -d Ubuntu-22.04 bash -lc 'which topgrade'`
DEBUG Executing command `C:\WINDOWS\system32\wsl.exe -d Ubuntu-22.04 bash -c 'TOPGRADE_PREFIX=Ubuntu-22.04 exec /home/maz/.cargo/bin/topgrade -v'`
DEBUG Configuration at /home/redacted/.config/topgrade.toml
DEBUG Loaded configuration: ConfigFile { include: Some(Include { paths: None }), misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: None, ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, cleanup: None, notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({}), post_commands: Some({}), commands: Some({}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: None, pipupgrade_arguments: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None, greedy_latest: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: None, windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: Some(Yarn { use_sudo: None }), vim: Some(Vim { force_plug_update: None }), firmware: Some(Firmware { upgrade: None }), vagrant: Some(Vagrant { directories: None, power_on: None, always_suspend: None }), flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }), lensfun: None }
DEBUG Version: 15.0.0
DEBUG OS: x86_64-unknown-linux-gnu
DEBUG Args { inner: ["/home/redacted/.cargo/bin/topgrade", "-v"] }
DEBUG Binary path: Ok("/home/redacted/.cargo/bin/topgrade")
DEBUG self-update Feature Enabled: true
DEBUG Configuration: Config { opt: CommandLineArgs { edit_config: false, show_config_reference: false, run_in_tmux: false, cleanup: false, dry_run: false, no_retry: false, disable: [], only: [], custom_commands: [], env: [], verbose: true, keep_at_end: false, skip_notify: false, yes: None, disable_predefined_git_repos: false, config: None, remote_host_limit: None, show_skipped: false, log_filter: "warn", gen_completion: None, gen_manpage: false, no_self_update: false }, config_file: ConfigFile { include: Some(Include { paths: None }), misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: None, ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, cleanup: None, notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({}), post_commands: Some({}), commands: Some({}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: None, pipupgrade_arguments: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None, greedy_latest: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: None, windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: Some(Yarn { use_sudo: None }), vim: Some(Vim { force_plug_update: None }), firmware: Some(Firmware { upgrade: None }), vagrant: Some(Vagrant { directories: None, power_on: None, always_suspend: None }), flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }), lensfun: None }, allowed_steps: [AM, AppMan, Asdf, Atom, Audit, AutoCpufreq, Bin, Bob, BrewCask, BrewFormula, Bun, BunPackages, Cargo, Certbot, Chezmoi, Chocolatey, Choosenim, ClamAvDb, Composer, Conda, ConfigUpdate, Containers, CustomCommands, DebGet, Deno, Distrobox, DkpPacman, Dotnet, Elan, Emacs, Firmware, Flatpak, Flutter, Fossil, Gcloud, Gem, Ghcup, GithubCliExtensions, GitRepos, GnomeShellExtensions, Go, Guix, Haxelib, Helm, HomeManager, Jetpack, Julia, Juliaup, Kakoune, Helix, Krew, Lure, Lensfun, Macports, Mamba, Miktex, Mas, Maza, Micro, Mise, Myrepos, Nix, Node, Opam, Pacdef, Pacstall, Pearl, Pip3, PipReview, PipReviewLocal, Pipupgrade, Pipx, Pkg, Pkgin, PlatformioCore, Pnpm, Powershell, Protonup, Pyenv, Raco, Rcm, Remotes, Restarts, Rtcl, RubyGems, Rustup, Rye, Scoop, Sdkman, SelfUpdate, Sheldon, Shell, Snap, Sparkle, Spicetify, Stack, Stew, System, Tldr, Tlmgr, Tmux, Toolbx, Vagrant, Vcpkg, Vim, Vscode, Waydroid, Winget, Wsl, WslUpdate, Xcodes, Yadm, Yarn] }
DEBUG Cannot find "pwsh"
DEBUG Cannot find "powershell"
DEBUG Path "/home/redacted/.config/emacs" doesn't exist
DEBUG Path "/home/redacted/.emacs.d" doesn't exist
DEBUG Cannot find "doas"
DEBUG Detected "/usr/bin/sudo" as "sudo"
DEBUG Step "Self Update"

── (Ubuntu-22.04) 16:26:06 - Self update ───────────────────────────────────────
Checking target-arch... x86_64-unknown-linux-gnu
Checking current version... v15.0.0
Checking latest released version... DEBUG starting new connection: https://api.github.com/
DEBUG proxy(http://alfortproxy.afssa.fr:8080) intercepts 'https://api.github.com/'
DEBUG resolving host="redacted.fr"
DEBUG connecting to 192.168.x.x:8080
DEBUG connected to 192.168.x.x:8080
DEBUG No cached session for DnsName("api.github.com")
DEBUG Not resuming any session
DEBUG Using ciphersuite TLS13_AES_128_GCM_SHA256
DEBUG Not resuming
DEBUG TLS1.3 encrypted extensions: [ServerNameAck, Protocols([ProtocolName(687474702f312e31)])]
DEBUG ALPN protocol is Some(b"http/1.1")
DEBUG pooling idle connection for ("https", api.github.com)
v15.0.0
Topgrade is up-to-date
DEBUG Step "packer.nu"
DEBUG Step "System update"

── (Ubuntu-22.04) 16:26:06 - System update ─────────────────────────────────────
DEBUG Cannot find "apt-fast"
DEBUG Cannot find "mist"
DEBUG Executing command `/usr/bin/sudo apt-get update`
[sudo] password for redacted:
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done
DEBUG Executing command `/usr/bin/sudo apt-get dist-upgrade`
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  python3-update-manager update-manager-core
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
DEBUG Step "config-update"
DEBUG Step "am"
DEBUG Step "appman"
DEBUG Step "deb-get"
DEBUG Step "toolbx"
DEBUG Step "snap"
DEBUG Detected "/usr/bin/snap" as "snap"

── (Ubuntu-22.04) 16:26:12 - snap ──────────────────────────────────────────────
DEBUG Executing command `/usr/bin/sudo /usr/bin/snap refresh`
error: unable to contact snap store
DEBUG Command failed: Err(
   0: Command failed: `/usr/bin/sudo /usr/bin/snap refresh`
   1: `/usr/bin/sudo` failed: exit status: 1

Location:
   src/steps/os/linux.rs:919)
DEBUG Step "snap" failed:
   0: Command failed: `/usr/bin/sudo /usr/bin/snap refresh`
   1: `/usr/bin/sudo` failed: exit status: 1

Location:
   src/steps/os/linux.rs:919
snap failed:
   0: Command failed: `/usr/bin/sudo /usr/bin/snap refresh`
   1: `/usr/bin/sudo` failed: exit status: 1

Location:
   src/steps/os/linux.rs:919
(Ubuntu-22.04) Retry? (y)es/(N)o/(s)hell/(q)uit
SteveLauC commented 4 months ago

For CLI options, I think there are indeed some options we need to pass to the remote host (WSL/VM/remote execution), e.g., see #557, #558, and my thought on this is that we should make all cli options platform-agnostic. For configuration files, I think we should respect the file on the host. I would like to hear your thoughts on this:)

Mazwak commented 4 months ago

Hello

I think that WSL is a special remote. I, myself, do not think it’s remote, it’s more a unix shell. In my head, it is the same host. Others might consider it a complete remote.

So, for me, I would prefer that it obeys my windows configuration, and use the same parameter as what was used from win cli.

For total remotes, physical or virtual, I agree that the remote should use the remote configuration. And I think it still should obey command-line arguments. So topgrade would update the intersection between configuration and command-line.