Hugo server preferring configured theme over command line

I’m confused with the behavior of hugo server when choosing which theme the render. Using the --theme <name> option should take precedence over whatever is inside config.yaml but that’s not the case. As long as I have theme: something inside my config.yaml, hugo will stubbornly ignore the value of my --theme option and render the something, although if I specify --theme with a nonexistent theme name, the build does fail.

Is that a bug? I’ll report it, if confirmed.

I vagely remember an issue with the themesDir flag… The workaround, which I guess will also work for this, is to set it as environment vars:

HUGO_THEME="mytheme" hugo server

Ah, I see, this was reported (and closed as duplicate) here (issue 5000).

The one you mentioned as “duplicate” is probably issue 4851, which is also closed. Does that mean the issue is already fixed and will be in the next release?

Running HUGO_THEME="mytheme" hugo server, while having theme: myothertheme in the config, does something weird. The home page is rendered from myothertheme, but when I click on any of the posts, I get 404 page not found – because mytheme is just a stub now with no templates.