rtkUpgrader took rtk for winget's only when its path had "/winget/" in
it. winget install --location "D:\codes\tools\rtk" puts rtk.exe in that
folder, and the link winget adds in WinGet\Links points there, so the
path once resolved had no "winget" in it: no Upgrade on the card, and
"magpie library rtk upgrade" said magpie can't tell how rtk was
installed, though winget upgrade --id rtk-ai.rtk works on it.
Now, on Windows, after the brew/winget-folder/cargo checks:
- the path heuristic also looks at the path rtk was found at, not only
the one its link leads to (WinGet\Links\rtk.exe);
- otherwise winget's own record decides: the entry winget writes for a
portable package under HKCU/HKLM ...\Uninstall
(rtk-ai.rtk_<source>, WinGetPackageIdentifier rtk-ai.rtk) names its
InstallLocation; rtk is winget's when it is in that folder, so an
rtk.exe copied elsewhere by hand isn't taken for winget's;
- with no record to read, winget list --id rtk-ai.rtk --exact is asked
through proc with a 15s timeout. The answer is kept 10 minutes per
rtk path, so the Library card doesn't run winget each time it is
drawn.
Siblings checked: rtkUpgrader is the only Library upgrader with a winget
path heuristic; its brew case matches /Cellar/rtk/, which every Homebrew
prefix has. Agents' CLI updates (internal/agent/cliupdate.go) and
magpie's own update know Homebrew by its Cellar only, and have no
winget, scoop or choco path rules.
Run:
- go test -tags nogui ./internal/library (sandbox HOME). New
rtk_winget_test.go with a fake winget (its list output from the test
box): the reporter's folder via the record (no winget run), a record
for another folder (and a name-prefix sibling folder) is not winget's,
winget list asked once per 10 minutes, unlisted/empty record/hung
winget are not winget's, the WinGet\Links link. Broke it four ways
(record check off, link check off, folder check as a bare prefix,
cache off) and each failed a test.
- Windows box (winget v1.29.380): winget install rtk-ai.rtk --location
D:\tools-1527\rtk. With rtk on PATH as D:\tools-1527\rtk\rtk.exe and
as WinGet\Links\rtk.exe: origin/main's "magpie library rtk upgrade"
says "magpie can't tell how the rtk ... was installed"; this build
runs winget upgrade ("winget's RTK is 0.50.0 so far; RTK 0.51.0 is
out"). A copy of rtk.exe in another folder is still "can't tell".
rtk uninstalled afterwards.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet on
internal/library.
7 lines
163 B
Go
7 lines
163 B
Go
//go:build !windows
|
|
|
|
package library
|
|
|
|
// rtkWingetLocations: winget's records are Windows' alone.
|
|
func rtkWingetLocations() ([]string, bool) { return nil, false }
|