Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go related steps fail after another step updated go and removed the old version #1039

Open
2 of 6 tasks
knutwalker opened this issue Feb 13, 2025 · 0 comments
Open
2 of 6 tasks
Labels
C-bug Something isn't working

Comments

@knutwalker
Copy link

Erroneous Behavior

I have go installed with mise, and I'm not really a go dev, so I installing it with mise is the most go action I've done in a while.

When I run topgrade and mise will update go, it also removes the previous installation (which is just what mise does, I suppose, nothing to do with topgrade).

However, when deciding on subsequent steps to do (namely, go-global-update and gup), topgrade fails when trying to figure out of those steps should be run. I don't have either of those tools installed, and the fallback check of checking go env GOPATH. This check now fails with

   0: Command failed: `/opt/homebrew/bin/go env GOPATH`

      Stderr:
      go: cannot find GOROOT directory: /Users/knut/.local/share/mise/installs/go/1.23.6
   1: `/opt/homebrew/bin/go` failed: exit status: 2 with go: cannot find GOROOT directory: /Users/knut/.local/share/mise/installs/go/1.23.6

Expected Behavior

I expected topgrade to skip the step, as it would on every other invocation when no go update happens.

Steps to reproduce

  1. Have go installed with mise (mise is not really important here, other tools should work as well if they also immediately remove the old version when upgrading)
  2. Make sure that go is not up-to-date (e.g. 1.23) and that the latest version is properly removed and unlinked and that go version returns the older version. Maybe also hash -d go and open a new terminal/shell to be sure.
  3. Don't have gup or go-global-update installed
  4. Run topgrade

Possible Cause (Optional)

Ultimately, this is more of a go/mise/caching issue.
I can open another terminal before running the update (e.g. where go version still points to 1.23).
The I run topgrade in another terminal, hitting the issue.
In the first terminal I run go env GOPATH to get the same error: go: cannot find GOROOT directory: /Users/knut/.local/share/mise/installs/go/1.23.6. However, after updating the binary cache (hash go or hash -d go), running go env GOPATH succeeds.

topgrade/src/steps/go.rs

Lines 33 to 43 in 66a12cc

let go = utils::require("go")?;
// TODO: Does this work? `go help gopath` says that:
// > The GOPATH environment variable lists places to look for Go code.
// > On Unix, the value is a colon-separated string.
// > On Windows, the value is a semicolon-separated string.
// > On Plan 9, the value is a list.
// Should we also fallback to the env variable?
let gopath_output = Command::new(go).args(["env", "GOPATH"]).output_checked_utf8()?;
let gopath = gopath_output.stdout.trim();
PathBuf::from(gopath).join("bin").join(name).require()

utils::require(name) will not find the tool, but utils::require("go") will find go and the command on line 40 fails.
Turning any error from running go env into a skip instead would likely fix this, but I'm not sure if it's a good idea in case a go env error is actually due to something else.

Also, I can "fix" it locally by adding go to the misc.disable config (though, neither go-global-update nor gup are accepted there, only go).
It works for me, since I don't really care about go otherwise, but it feels a bit like too big of a hammer to use.

Problem persists without calling from topgrade

  • Yes
  • No

As mentioned above, I can reproduce the error of running go env.

Did you run topgrade through Remote Execution

  • Yes
  • No

If yes, does the issue still occur when you run topgrade directlly in your
remote host

  • Yes
  • No

Additional Details

  • Operation System/Version

macOS 15.3.1

  • Installation

homebrew (which topgrade -> /opt/homebrew/bin/topgrade)

  • Topgrade version (topgrade -V)

topgrade 16.0.2

Verbose Output (topgrade -v)

❯ topgrade -v
DEBUG Current system locale is en-US
DEBUG Configuration at /Users/knut/.config/topgrade.toml
DEBUG Loaded configuration: ConfigFile { include: None, misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: Some([Conda, Gem, Helix, Node, Pip3, RubyGems, Sdkman, System, Tmux, Uv, Vim, Vscode, Zvm]), ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: Some(false), display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, tmux_session_mode: None, cleanup: None, notify_each_step: None, skip_notify: Some(true), bashit_branch: None, only: None, no_self_update: Some(true), log_filters: None }), pre_commands: None, post_commands: None, commands: None, python: None, composer: None, brew: Some(Brew { greedy_cask: Some(true), greedy_latest: None, greedy_auto_updates: None, autoremove: None, fetch_head: None }), linux: None, git: None, containers: None, windows: None, npm: None, yarn: None, deno: None, vim: None, firmware: None, vagrant: None, flatpak: None, distrobox: None, lensfun: None, julia: None }
DEBUG Version: 16.0.2
DEBUG OS: aarch64-apple-darwin
DEBUG Args { inner: ["topgrade", "-v"] }
DEBUG Binary path: Ok("/opt/homebrew/bin/topgrade")
DEBUG self-update Feature Enabled: false
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: None, misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: Some([Conda, Gem, Helix, Node, Pip3, RubyGems, Sdkman, System, Tmux, Uv, Vim, Vscode, Zvm]), ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: Some(false), display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, tmux_session_mode: None, cleanup: None, notify_each_step: None, skip_notify: Some(true), bashit_branch: None, only: None, no_self_update: Some(true), log_filters: None }), pre_commands: None, post_commands: None, commands: None, python: None, composer: None, brew: Some(Brew { greedy_cask: Some(true), greedy_latest: None, greedy_auto_updates: None, autoremove: None, fetch_head: None }), linux: None, git: None, containers: None, windows: None, npm: None, yarn: None, deno: None, vim: None, firmware: None, vagrant: None, flatpak: None, distrobox: None, lensfun: None, julia: None }, allowed_steps: [AM, AppMan, Asdf, Atom, Aqua, Audit, AutoCpufreq, Bin, Bob, BrewCask, BrewFormula, Bun, BunPackages, Cargo, Certbot, Chezmoi, Chocolatey, Choosenim, ClamAvDb, Composer, ConfigUpdate, Containers, CustomCommands, DebGet, Deno, Distrobox, DkpPacman, Dotnet, Elan, Emacs, Firmware, Flatpak, Flutter, Fossil, Gcloud, Ghcup, GithubCliExtensions, GitRepos, GnomeShellExtensions, Go, Guix, Haxelib, Helm, HomeManager, Jetpack, Julia, Juliaup, Kakoune, Krew, Lure, Lensfun, Macports, Mamba, Miktex, Mas, Maza, Micro, MicrosoftStore, Mise, Myrepos, Nix, Opam, Pacdef, Pacstall, Pearl, PipReview, PipReviewLocal, Pipupgrade, Pipx, Pixi, Pkg, Pkgin, PlatformioCore, Pnpm, Poetry, Powershell, Protonup, Pyenv, Raco, Rcm, Remotes, Restarts, Rtcl, Rustup, Rye, Scoop, SelfUpdate, Sheldon, Shell, Snap, Sparkle, Spicetify, Stack, Stew, Tldr, Tlmgr, Toolbx, Vagrant, Vcpkg, VoltaPackages, Waydroid, Winget, Wsl, WslUpdate, Xcodes, Yadm, Yarn] }
DEBUG Cannot find "pwsh"
DEBUG Cannot find "powershell"
DEBUG Path "/Users/knut/.config/emacs" doesn't exist
DEBUG Path "/Users/knut/.emacs.d" doesn't exist
DEBUG Cannot find "doas"
DEBUG Detected "/usr/bin/sudo" as "sudo"
DEBUG Step "Brew (ARM)"
DEBUG Detected "/opt/homebrew/bin/brew" as "/opt/homebrew/bin/brew"

── 20:51:24 - Brew ─────────────────────────────────────────────────────────────
DEBUG Executing command /opt/homebrew/bin/brew update
==> Updating Homebrew...
Already up-to-date.
DEBUG Executing command /opt/homebrew/bin/brew upgrade --formula
DEBUG Step "Brew (Intel)"
DEBUG Step "Brew"
DEBUG Detected "/opt/homebrew/bin/brew" as "brew"
DEBUG Step "Brew Cask (ARM)"
DEBUG Detected "/opt/homebrew/bin/brew" as "/opt/homebrew/bin/brew"

── 20:51:27 - Brew - Cask ──────────────────────────────────────────────────────
DEBUG Executing command /opt/homebrew/bin/brew --repository buo/cask-upgrade
DEBUG Executing command /opt/homebrew/bin/brew upgrade --cask --greedy
DEBUG Step "Brew Cask (Intel)"
DEBUG Step "Brew Cask"
DEBUG Detected "/opt/homebrew/bin/brew" as "brew"
DEBUG Step "MacPorts"
DEBUG Step "Xcodes"
DEBUG Step "Sparkle"
DEBUG Step "App Store"
DEBUG Step "yadm"
DEBUG Step "nix"
DEBUG Step "nix upgrade-nix"
DEBUG Step "guix"
DEBUG Step "home-manager"
DEBUG Step "asdf"
DEBUG Step "mise"
DEBUG Detected "/opt/homebrew/opt/mise/bin/mise" as "mise"

── 20:51:28 - mise ─────────────────────────────────────────────────────────────
DEBUG Executing command /opt/homebrew/opt/mise/bin/mise plugins update
mise plugin:usage update git repo ⠁ 0s
mise plugin:usage ✓ https://github.com/jdx/mise-usage.git#fe3888a
mise plugin:maven ✓ https://github.com/mise-plugins/asdf-maven.git#c872214
mise plugin:jbang ✓ https://github.com/jbangdev/jbang-asdf.git#96c41a7
mise plugin:gradle ✓ https://github.com/version-fox/vfox-gradle.git#6aa59ab DEBUG Executing command /opt/homebrew/opt/mise/bin/mise upgrade
mise [email protected] ✓ installed
mise uninstall [email protected] ✓ remove ~/.cache/mise/go/1.23.6 DEBUG Step "pkgin"
DEBUG Step "bun-packages"
DEBUG Step "zr"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Step "antibody"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Step "antidote"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Step "antigen"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Step "zgenom"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Step "zplug"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Step "zinit"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Step "zi"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Step "zim"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Executing command zsh -c '[[ -n ${ZIM_HOME} ]] && print -n ${ZIM_HOME}'
DEBUG Command failed: Err(
0: Command failed: zsh -c '[[ -n ${ZIM_HOME} ]] && print -n ${ZIM_HOME}'
1: zsh failed: exit status: 1 with

Location:
src/steps/zsh.rs:153)
DEBUG Step "oh-my-zsh"
DEBUG Detected "/bin/zsh" as "zsh"
DEBUG Step "oh-my-bash"
DEBUG Detected "/opt/homebrew/bin/bash" as "bash"
DEBUG Step "fisher"
DEBUG Detected "/opt/homebrew/bin/fish" as "fish"
DEBUG Executing command /opt/homebrew/bin/fish -c 'type -t fisher'
DEBUG Command failed: Err(
0: Command failed: /opt/homebrew/bin/fish -c 'type -t fisher'

  Stderr:
  type: Could not find 'fisher'

1: /opt/homebrew/bin/fish failed: exit status: 1 with type: Could not find 'fisher'
1:

Location:
src/steps/os/unix.rs:105)
DEBUG Step "bash-it"
DEBUG Step "oh-my-fish"
DEBUG Detected "/opt/homebrew/bin/fish" as "fish"
DEBUG Step "fish-plug"
DEBUG Detected "/opt/homebrew/bin/fish" as "fish"
DEBUG Step "fundle"
DEBUG Detected "/opt/homebrew/bin/fish" as "fish"
DEBUG Step "TLDR"
DEBUG Step "pearl"
DEBUG Step "pyenv"
DEBUG Step "rcm"
DEBUG Step "maza"
DEBUG Step "apm"
DEBUG Step "fossil"
DEBUG Step "elan"
DEBUG Step "rye"
DEBUG Step "rustup"
DEBUG Detected "/Users/knut/.cargo/bin/rustup" as "rustup"

── 20:51:36 - rustup ───────────────────────────────────────────────────────────
DEBUG Executing command /Users/knut/.cargo/bin/rustup update
info: syncing channel updates for 'stable-aarch64-apple-darwin'
info: syncing channel updates for 'nightly-aarch64-apple-darwin'
info: checking for self-update

stable-aarch64-apple-darwin unchanged - rustc 1.84.1 (e71f9a9a9 2025-01-27)
nightly-aarch64-apple-darwin unchanged - rustc 1.86.0-nightly (ef148cd7e 2025-02-12)

info: cleaning up downloads & tmp directories
DEBUG Step "juliaup"
DEBUG Step ".NET"
DEBUG Step "choosenim"
DEBUG Step "cargo"
DEBUG Path "/Users/knut/.cargo" exists
DEBUG Detected "/Users/knut/.cargo/bin/cargo" as "cargo"
DEBUG Path "/Users/knut/.cargo/.crates.toml" exists

── 20:51:36 - Cargo ────────────────────────────────────────────────────────────
DEBUG Detected "/Users/knut/.cargo/bin/cargo-install-update" as "cargo-install-update"
DEBUG Executing command /Users/knut/.cargo/bin/cargo-install-update install-update --git --all
Polling registry 'https://index.crates.io/'........

Package Installed Latest Needs update
cargo-doc2readme v0.5.0 =0.5.0 No
cargo-expand v1.0.90 =1.0.90 No
cargo-update v14.0.0 =14.0.0 No
cargo-whatfeatures v0.9.13 v0.9.13 No
cw v0.7.0 =0.7.0 No
evcxr_repl v0.18.0 =0.18.0 No
pik v0.10.0 =0.10.0 No
samply v0.13.1 =0.13.1 No

No packages need updating.
Package Installed Latest Needs update
pdfrip 461fe2f50f26ee0397f9670923fd3727cc3b7d3b 461fe2f50f26ee0397f9670923fd3727cc3b7d3b No

No git packages need updating.
Overall updated 0 packages.
DEBUG Step "Flutter"
DEBUG Step "go-global-update"
DEBUG Detected "/opt/homebrew/bin/go" as "go"
DEBUG Executing command /opt/homebrew/bin/go env GOPATH
DEBUG Command failed: Err(
0: Command failed: /opt/homebrew/bin/go env GOPATH

  Stderr:
  go: cannot find GOROOT directory: /Users/knut/.local/share/mise/installs/go/1.23.6

1: /opt/homebrew/bin/go failed: exit status: 2 with go: cannot find GOROOT directory: /Users/knut/.local/share/mise/installs/go/1.23.6
1:

Location:
src/steps/go.rs:40)
DEBUG Step "go-global-update" failed:
0: Command failed: /opt/homebrew/bin/go env GOPATH

  Stderr:
  go: cannot find GOROOT directory: /Users/knut/.local/share/mise/installs/go/1.23.6

1: /opt/homebrew/bin/go failed: exit status: 2 with go: cannot find GOROOT directory: /Users/knut/.local/share/mise/installs/go/1.23.6
1:

Location:
src/steps/go.rs:40
go-global-update failed:
0: Command failed: /opt/homebrew/bin/go env GOPATH

  Stderr:
  go: cannot find GOROOT directory: /Users/knut/.local/share/mise/installs/go/1.23.6

1: /opt/homebrew/bin/go failed: exit status: 2 with go: cannot find GOROOT directory: /Users/knut/.local/share/mise/installs/go/1.23.6
1:

Location:
src/steps/go.rs:40
Retry? (y)es/(N)o/(s)hell/(q)uit⏎

@knutwalker knutwalker added the C-bug Something isn't working label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant