Skip to content

Commit 2cee972

Browse files
committed
Provide warning message for unnecessary sudo
If minikube is started with root privilege and vm-driver is not hyperV or none, then a warning message is displayed.
1 parent eb96756 commit 2cee972

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/minikube/cmd/start.go

+10
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,15 @@ 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 {
180+
glog.Errorf("Error getting the current user: %v", err)
181+
} else if currentUser.Name == "root" && !(viper.GetString(vmDriver) == "hyperv" || viper.GetString(vmDriver) == "none") {
182+
console.OutStyle(console.WarningType, "Please don't run minikube as root or with 'sudo' privileges. It isn't necessary.")
183+
}
184+
175185
oldConfig, err := cfg.Load()
176186
if err != nil && !os.IsNotExist(err) {
177187
exit.WithCode(exit.Data, "Unable to load config: %v", err)

0 commit comments

Comments
 (0)