magpie icon indicating copy to clipboard operation
magpie copied to clipboard

[Bug] 资源库升级 RTK 失败:cargo install 未指定包名,报 multiple packages with binaries found

Open rfiacne opened this issue 1 month ago • 4 comments

环境

  • 应用:Magpie(资源库 > RTK > 升级)
  • 系统:Windows(Windows_NT 10.0.26200)
  • rustc 1.98.1 (48a229cea 2026-09-01)
  • cargo 1.98.1 (797e8a9bc 2026-08-05)

问题

在 Magpie 资源库点击 RTK「升级」时报错:

升级失败:cargo failed (exit code 101) — Updating git repository 'https://github.com/rtk-ai/rtk'
error: multiple packages with binaries found: rtk, rtk-proxy. Please specify a package, e.g. cargo install --git https://github.com/rtk-ai/rtk rtk.

原因

rtk 1.0 起仓库包含多个 binary 包(rtk、rtk-proxy),而 Magpie 升级时执行的 cargo install --git https://github.com/rtk-ai/rtk 未指定包名,cargo 无法确定安装目标。

rfiacne avatar Oct 14 '26 03:10 rfiacne

Hi, I'd like to take this one.

I reproduced it on macOS (cargo 1.95.0) with the exact command magpie runs — internal/library/rtk_upgrade.go:350:

$ cargo install --git https://github.com/rtk-ai/rtk --force
error: multiple packages with binaries found: rtk, rtk-proxy. When installing a git repository, cargo will always search the entire repo for any Cargo.toml.
Please specify a package, e.g. `cargo install --git https://github.com/rtk-ai/rtk rtk`.

Root cause: since rtk added the rtk-proxy binary, a bare cargo install --git can no longer resolve which binary to install. rtk's own Cargo.toml documents the install command with the package named explicitly (cargo install --git <url> rtk). The fix is to pass that package name in magpie's cargo upgrader.

PR coming shortly. (This contribution was prepared with AI assistance; the reproduction, fix and testing were reviewed by me.)

akushonkamen avatar Oct 14 '26 05:10 akushonkamen

Update: the fix is ready on my fork — akushonkamen/magpie@fix/2092-cargo-install-package, commit f4bda97e5e8d5a70703f9466d3916cb79a62c0e9:

  • internal/library/rtk_upgrade.go: the cargo upgrader now runs cargo install --git https://github.com/rtk-ai/rtk rtk --force (the package named, as rtk's own Cargo.toml documents), since the repo holds rtk and rtk-proxy
  • internal/library/rtk_upgrade_test.go: TestRTKCargoUpgraderNamesPackage (red before, green after; the whole internal/library package passes)

Verified end to end on macOS/cargo 1.95.0: the old command fails with the error in this issue; the fixed command installs rtk v0.49.0 cleanly.

Opening the pull request from here is being refused by GitHub ("does not have the correct permissions to execute CreatePullRequest" / HTTP 404 on POST /repos/yetone/magpie/pulls, while issue comments and PRs on my own fork work) — this looks like a repository-side limit on who can open PRs, so I'm leaving the branch here: yetone/magpie main ← `akushonkamen:magpiefix/2092-cargo-install-package. Happy to resubmit if the restriction is lifted or I'm missing something.

akushonkamen avatar Oct 14 '26 05:10 akushonkamen

nice one! I see the lastest version has the problem fixed!

rfiacne avatar Oct 14 '26 05:10 rfiacne

@rfiacne @yetone The issue is actually not fixed yet on main.

Checking internal/library/rtk_upgrade.go:350 on main, the command is still:

case dir == filepath.Join(home(), ".cargo", "bin"):
	if have("cargo") {
		return []string{"cargo", "install", "--git", "https://github.com/rtk-ai/rtk", "--force"}
	}

As a result, clicking "Upgrade" in Magpie on any machine with cargo RTK still fails with exit code 101:

升级失败: cargo failed (exit code 101) — Updating git repository 'https://github.com/rtk-ai/rtk' 
error: multiple packages with binaries found: rtk, rtk-proxy.

Since GitHub prevents external contributors from opening PRs on this repo (does not have the correct permissions to execute CreatePullRequest), could @yetone please apply the 1-word fix directly on main? Branch with test: https://github.com/Beyfish/magpie/tree/fix/rtk-cargo-install-specify-package (commit: 3b56e33)

--- a/internal/library/rtk_upgrade.go
+++ b/internal/library/rtk_upgrade.go
@@ -347,7 +347,7 @@ func rtkUpgrader(bin string) []string {
 	case dir == filepath.Join(home(), ".cargo", "bin"):
 		if have("cargo") {
-			return []string{"cargo", "install", "--git", "https://github.com/rtk-ai/rtk", "--force"}
+			return []string{"cargo", "install", "--git", "https://github.com/rtk-ai/rtk", "rtk", "--force"}
 		}

Beyfish avatar Oct 15 '26 06:10 Beyfish