What Happened?
Two commands register local flags with cobra but read them via viper.GetBool() without
binding the flag to viper. Since viper doesn't know about the flag, it always returns the
default value (false), and the flag is silently ignored.
Affected commands
minikube cache add --all
The --all flag is registered on addCacheCmd (cache.go:66) but read via
viper.GetBool("all") (cache.go:70). There is no viper.BindPFlags call for
addCacheCmd, so viper never sees the flag value.
Result: --all is silently ignored. Images are always loaded to the current profile
only, never to all profiles.
// cache.go:66 - flag registered on cobra
addCacheCmd.Flags().Bool(allFlag, false, "Add image to cache for all running minikube clusters")
// cache.go:70 - read via viper (never bound)
if viper.GetBool(allFlag) {
minikube node start --delete-on-failure
The --delete-on-failure flag is registered on nodeStartCmd (node_start.go:89) but
read via viper.GetBool(deleteOnFailure) (node_start.go:63). There is no
viper.BindPFlags call for nodeStartCmd.
Result: --delete-on-failure is silently ignored. The cluster is never deleted and
retried on failure.
// node_start.go:89 - flag registered on cobra
nodeStartCmd.Flags().Bool(deleteOnFailure, false, "If set, delete the current cluster if start fails and try again. Defaults to false.")
// node_start.go:63 - read via viper (never bound)
r, p, m, h, err := node.Provision(cc, n, viper.GetBool(deleteOnFailure), options)
Root cause
Viper has a single global namespace. Cobra has per-command flag sets. When a flag is
registered on a subcommand, it must be explicitly bound to viper via viper.BindPFlags()
for viper.Get*() to see it.
Only 3 commands bind their flags:
root.go — RootCmd.PersistentFlags() (global flags like --profile)
start.go — startCmd.Flags()
delete.go — deleteCmd.Flags()
All other commands that read local flags via viper.Get*() are broken.
Why BindPFlags can't simply be added
Multiple commands use the same flag names (e.g. --all on cache add, delete, and
stop). Since all init() functions run at startup regardless of which command is
invoked, binding the same name from multiple commands causes collisions — the last
binding wins.
Fix
minikube cache is deprecated — remove it instead of fixing.
minikube node start --delete-on-failure never worked — remove the flag. Nobody
has complained about it, confirming it is not needed.
What Happened?
Two commands register local flags with cobra but read them via
viper.GetBool()withoutbinding the flag to viper. Since viper doesn't know about the flag, it always returns the
default value (
false), and the flag is silently ignored.Affected commands
minikube cache add --allThe
--allflag is registered onaddCacheCmd(cache.go:66) but read viaviper.GetBool("all")(cache.go:70). There is noviper.BindPFlagscall foraddCacheCmd, so viper never sees the flag value.Result:
--allis silently ignored. Images are always loaded to the current profileonly, never to all profiles.
minikube node start --delete-on-failureThe
--delete-on-failureflag is registered onnodeStartCmd(node_start.go:89) butread via
viper.GetBool(deleteOnFailure)(node_start.go:63). There is noviper.BindPFlagscall fornodeStartCmd.Result:
--delete-on-failureis silently ignored. The cluster is never deleted andretried on failure.
Root cause
Viper has a single global namespace. Cobra has per-command flag sets. When a flag is
registered on a subcommand, it must be explicitly bound to viper via
viper.BindPFlags()for
viper.Get*()to see it.Only 3 commands bind their flags:
root.go—RootCmd.PersistentFlags()(global flags like--profile)start.go—startCmd.Flags()delete.go—deleteCmd.Flags()All other commands that read local flags via
viper.Get*()are broken.Why
BindPFlagscan't simply be addedMultiple commands use the same flag names (e.g.
--alloncache add,delete, andstop). Since allinit()functions run at startup regardless of which command isinvoked, binding the same name from multiple commands causes collisions — the last
binding wins.
Fix
minikube cacheis deprecated — remove it instead of fixing.minikube node start --delete-on-failurenever worked — remove the flag. Nobodyhas complained about it, confirming it is not needed.