Page MenuHomePhabricator

mw update fails with 'unknown userid' error
Closed, ResolvedPublic

Description

I'm trying to use mwcli for the first time, following the Installation guide. The Download and Install steps went as expected, but when running sudo mw update I get the following error:

panic: user: unknown userid 501

goroutine 1 [running]:
gitlab.wikimedia.org/repos/releng/cli/internal/cli.LegacyUserDirectoryPath()
	/builds/repos/releng/cli/internal/cli/dir.go:75 +0xc8
gitlab.wikimedia.org/repos/releng/cli/cmd.Execute({0x20f3ea8?, 0x1005e99?}, {0x20f3084?, 0x0?}, {0x20f308c?, 0x1d1f160?}, {0x20f3eb0, 0x7}, {0x20f6dd0, 0x14}, ...)
	/builds/repos/releng/cli/cmd/root.go:176 +0x177
main.main()
	/builds/repos/releng/cli/main.go:29 +0x85

I'm attempting to install on an M1 MacBook Pro, Ventura 13.5.

mw version -vv output:

Version Information  Value                                                     
GitCommit            7ab3d23                                                   
GitBranch            HEAD                                                      
GitState             clean                                                     
GitSummary           v0.22.1                                                   
BuildDate            2023-03-16T18:30:31Z                                      
Version              0.22.1                                                    
Releases             https://gitlab.wikimedia.org/repos/releng/cli/-/releases

Event Timeline

In 0.20.0 I removed any suggestions of running the commands with sudo as it complicates things internally.
See https://gitlab.wikimedia.org/repos/releng/cli/-/blob/main/CHANGELOG.md#v0200

If you just run mw update I'm pretty sure it will download the file and output a command you can sudo with to get the update in the location of your binary

Okay, scratch that, sudo mw update seems to work fine for me...

LegacyUserDirectoryPath relates to moving config from an old location to a new location https://gitlab.wikimedia.org/repos/releng/cli/-/blob/main/internal/cli/dir.go#L40
this does fancy root / sudo checking stuff https://gitlab.wikimedia.org/repos/releng/cli/-/blob/main/internal/cli/dir.go#L52

This migration and path lookup is always run
https://gitlab.wikimedia.org/repos/releng/cli/-/blob/main/cmd/root.go#L173-175
And thus no command will work with sudo for you currently

I suggest updating the binary manually for now
You can find a download on the latest release at https://gitlab.wikimedia.org/repos/releng/cli/-/releases/v0.23.0

I'll try and fix this moving forward

Samwalton9-WMF claimed this task.

In 0.20.0 I removed any suggestions of running the commands with sudo as it complicates things internally.
See https://gitlab.wikimedia.org/repos/releng/cli/-/blob/main/CHANGELOG.md#v0200

If you just run mw update I'm pretty sure it will download the file and output a command you can sudo with to get the update in the location of your binary

Thanks! Just doing mw update resolved this for me and I got the 0.23.0 update as expected.

Should https://www.mediawiki.org/wiki/Cli/guide/Installation be updated?