[Bug] 资源库升级 RTK 失败:cargo install 未指定包名,报 multiple packages with binaries found(#2092 尚未在 main 修复)
环境
- 系统:Windows / macOS / Linux
- 组件:Magpie(资源库 > RTK > 升级)
- 触发条件:RTK 安装在
~/.cargo/bin
问题描述
在 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.
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'.
原因分析
之前曾有 Issue #2092 反馈过该问题,但当时提 issue 的用户误以为已修复而自行关闭了该 issue。
查验最新的 main 分支代码 internal/library/rtk_upgrade.go:350,目前依然是:
case dir == filepath.Join(home(), ".cargo", "bin"):
if have("cargo") {
return []string{"cargo", "install", "--git", "https://github.com/rtk-ai/rtk", "--force"}
}
由于 RTK v1.0.0 之后拆分为包含 rtk 和 rtk-proxy 两个二进制的 workspace,cargo 要求必须显式传包名参数。
建议修复(仅供参考)
--- 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"}
}
case !rtkOnWindows:
补丁接 #2328,采用报告者 Beyfish 的定位与建议的一行修复。
根因:RTK 1.0 起仓库同时含 rtk 与 rtk-proxy 两个 binary,cargo install --git 搜全仓后拒绝二选一,cargo 的报错自己给出了修法(指定包名)。#2092 被误关后 main 一直未修;main 上最近一次动到 rtkUpgrader 的提交(e0a3b8c6,#1178)不涉及此行。
修法:internal/library/rtk_upgrade.go 的 cargo 分支补上包名 rtk。这是 magpie 里唯一跑 cargo 的路径:页面安装走 Homebrew/winget/官方脚本,cargo 分支是唯一从仓库构建的。
验证(Windows 11,go1.26.5;目标包测试自带临时目录隔离):
| 命令 | 结果 |
|---|---|
消融基线(checkout 231d2f14~1 的 rtk_upgrade.go)go test -tags nogui -count=1 -run '^TestRTKUpgraderCargoNamesThePackage$' ./internal/library/ |
红:命令缺包名,与报告复现同形 |
| 恢复修复后同命令 | 绿 |
gofmt -l internal/library/ / go vet ./internal/library/ / GOOS=linux go vet -tags nogui ./internal/library/ / go build .(windows) |
全干净 |
新增 TestRTKUpgraderCargoNamesThePackage |
修前红、修后绿 |
没跑:全量 ./...(本机 library 包另有 3 个预存 Windows 红,#2275 在案)、-race、darwin 构建、真实 cargo 升级一次。
0001-rtk-cargo-s-upgrader-names-the-package-it-installs.patch(format-patch 全文)
From: ggbdpq <[email protected]>
Date: Thu, 15 Oct 2026 16:52:33 +0800
Subject: [PATCH] =?UTF-8?q?rtk:=20cargo's=20upgrader=20names=20the=20packa?=
=?UTF-8?q?ge=20it=20installs=20(#2328)=20=E2=80=94=20RTK=201.0's=20reposi?=
=?UTF-8?q?tory=20keeps=20rtk-proxy=20beside=20rtk,=20and=20cargo=20instal?=
=?UTF-8?q?l=20--git=20searches=20the=20whole=20repository=20and=20refuses?=
=?UTF-8?q?=20to=20choose=20between=20binaries,=20so=20the=20upgrade=20of?=
=?UTF-8?q?=20one=20installed=20in=20~/.cargo/bin=20failed=20with=20"multi?=
=?UTF-8?q?ple=20packages=20with=20binaries=20found:=20rtk,=20rtk-proxy"?=
=?UTF-8?q?=20every=20time;=20#2092=20said=20so=20and=20was=20closed=20on?=
=?UTF-8?q?=20the=20belief=20it=20had=20been=20fixed.=20The=20package=20is?=
=?UTF-8?q?=20named=20now,=20as=20cargo's=20own=20error=20asks:=20cargo=20?=
=?UTF-8?q?install=20--git=20https://github.com/rtk-ai/rtk=20rtk=20--force?=
=?UTF-8?q?.=20It=20is=20the=20one=20place=20cargo=20is=20run:=20an=20inst?=
=?UTF-8?q?all=20from=20the=20page=20goes=20through=20Homebrew,=20winget?=
=?UTF-8?q?=20or=20rtk's=20own=20script,=20and=20the=20cargo=20branch=20is?=
=?UTF-8?q?=20the=20only=20one=20that=20builds=20from=20the=20repository.?=
=?UTF-8?q?=20TestRTKUpgraderCargoNamesThePackage=20fails=20without=20the?=
=?UTF-8?q?=20change:=20the=20upgrader=20had=20no=20package=20in=20its=20c?=
=?UTF-8?q?ommand.=20go=20vet,=20go=20test=20-tags=20nogui=20-run=20TestRT?=
=?UTF-8?q?K=20./internal/library/=20pass.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes #2328
Generated-by: GLM-5.3-Flash (ZCode)
---
internal/library/rtk_upgrade.go | 4 +++-
internal/library/rtk_upgrade_test.go | 15 +++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/internal/library/rtk_upgrade.go b/internal/library/rtk_upgrade.go
index f1969257..889cc720 100644
--- a/internal/library/rtk_upgrade.go
+++ b/internal/library/rtk_upgrade.go
@@ -347,7 +347,9 @@ 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"}
+ // the package named: RTK 1.0's repository has rtk-proxy beside
+ // rtk, and cargo install --git picks between binaries none (#2092)
+ return []string{"cargo", "install", "--git", "https://github.com/rtk-ai/rtk", "rtk", "--force"}
}
case !rtkOnWindows:
// its own script, told the folder it is in (RTK_INSTALL_DIR): the
diff --git a/internal/library/rtk_upgrade_test.go b/internal/library/rtk_upgrade_test.go
index 0f3c411b..ca1ba4f5 100644
--- a/internal/library/rtk_upgrade_test.go
+++ b/internal/library/rtk_upgrade_test.go
@@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"runtime"
+ "slices"
"strings"
"testing"
"time"
@@ -306,3 +307,17 @@ func TestRTKChannelVersion(t *testing.T) {
}
}
}
+
+// RTK 1.0's repository carries two binaries, rtk and rtk-proxy, so cargo
+// install --git refuses to choose and fails with "multiple packages with
+// binaries found" until the package is named (#2092, #2328).
+func TestRTKUpgraderCargoNamesThePackage(t *testing.T) {
+ h := sandbox(t)
+ testenv.Program(t, filepath.Join(h, "bin", "cargo"), "#!/bin/sh\n")
+ write(t, filepath.Join(h, "bin", "cargo.exe"), "")
+ c := rtkUpgrader(filepath.Join(home(), ".cargo", "bin", "rtk"))
+ want := []string{"cargo", "install", "--git", "https://github.com/rtk-ai/rtk", "rtk", "--force"}
+ if !slices.Equal(c, want) {
+ t.Fatalf("the cargo upgrader: %q; want %q", c, want)
+ }
+}
--
2.55.0.windows.4
- fork 分支:https://github.com/ggbdpq/magpie/tree/hunt25-l3-2328(head
231d2f14) - 合入时请保留原作者(git am / cherry-pick),或加
Co-authored-by: ggbdpq <[email protected]>
Generated-by: GLM-5.3-Flash (ZCode)
确认修复已进 main:63c0c35 中 cargo 分支已带上包名(cargo install --git https://github.com/rtk-ai/rtk rtk --force),v0.1.1411 起的构建包含此改动。
我在本地(go1.26.2 / Windows 11)checkout 最新 main 验证过这一行,与报告中的复现路径一致。感谢 @ggbdpq 的补丁,可以关闭了。
Thanks @Beyfish for confirming and for verifying on a local checkout.
Confirming as the patch author: the fix landed upstream as fb3ceac2b8b631090ba1cce3449818fea7524bde — the cargo branch in internal/library/rtk_upgrade.go now runs cargo install --git https://github.com/rtk-ai/rtk rtk --force, with the package named. @yetone kept the Co-authored-by credit, thank you.
The fix is in builds since v0.1.1411. @yetone this can be closed.
跟进一下关闭条件:修复已进入 main(fb3ceac2b8b631090ba1cce3449818fea7524bde,cargo 分支现为 cargo install --git https://github.com/rtk-ai/rtk rtk --force),随 v0.1.1411 起的构建发布;我和补丁作者 @ggbdpq 都已核对过代码,本机当前为 v0.1.3853,没有待补的复验材料。
@yetone 建议关闭本 issue;若之后再复现,我会带上版本与升级日志重开。