diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 4b26de05a9..b91dfdcd09 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -242,8 +242,22 @@ func init() { consoleFlags, debug.Flags, metricsFlags, + []cli.Flag{utils.NoEnvironmentFlag}, ) - flags.AutoEnvVars(app.Flags, "GETH") + + noenv := false + for _, arg := range os.Args { + flag := strings.TrimLeft(arg, "-") + if flag == utils.NoEnvironmentFlag.Name { + log.Info("Disables the use of environment variables for configuration") + noenv = true + break + } + } + + if !noenv { + flags.AutoEnvVars(app.Flags, "GETH") + } app.Before = func(ctx *cli.Context) error { maxprocs.Set() // Automatically set GOMAXPROCS to match Linux container CPU quota. @@ -251,7 +265,9 @@ func init() { if err := debug.Setup(ctx); err != nil { return err } - flags.CheckEnvVars(ctx, app.Flags, "GETH") + if !noenv { + flags.CheckEnvVars(ctx, app.Flags, "GETH") + } return nil } app.After = func(ctx *cli.Context) error { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c172d269c5..ce95270b3d 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -949,6 +949,12 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server. Value: metrics.DefaultConfig.InfluxDBOrganization, Category: flags.MetricsCategory, } + + NoEnvironmentFlag = &cli.BoolFlag{ + Name: "noenv", + Usage: "Disables the use of environment variables for configuration", + Category: flags.MiscCategory, + } ) var (