Skip to content

Commit a7a0f61

Browse files
committed
Issue : #4420 - Provide warning message for unnecessary sudo
Fixes #4420. If minikue is started with root privilege and vm-driver is not hyperv, then a warning message is displayed.
1 parent 6aa51c1 commit a7a0f61

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: cmd/minikube/cmd/start.go

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"net"
2424
"os"
2525
"os/exec"
26+
"os/user"
2627
"path/filepath"
2728
"runtime"
2829
"strconv"
@@ -172,6 +173,13 @@ func runStart(cmd *cobra.Command, args []string) {
172173
console.OutStyle(console.Happy, "minikube %s on %s (%s)", version.GetVersion(), runtime.GOOS, runtime.GOARCH)
173174
validateConfig()
174175

176+
currentUser, err := user.Current()
177+
178+
// Display warning if minikube is being started with root and vmDriver is not hyperv
179+
if err == nil && currentUser.Name == "root" && viper.GetString(vmDriver) != "hyperv" {
180+
console.OutStyle(console.WarningType, "Please don't run minikube as root or with 'sudo' privileges. It isn't necessary.")
181+
}
182+
175183
oldConfig, err := cfg.Load()
176184
if err != nil && !os.IsNotExist(err) {
177185
exit.WithCode(exit.Data, "Unable to load config: %v", err)

0 commit comments

Comments
 (0)