From 4da6ed049b874150be19865f46b3b631b04785a1 Mon Sep 17 00:00:00 2001 From: Fred Carle Date: Mon, 29 Jan 2024 16:54:12 -0500 Subject: [PATCH] fix: Load root dir before loading config (#2266) ## Relevant issue(s) Resolves #2264 ## Description This PR ensures that the root dir path gets defined prior to looking for a config file. It fixes an issue where the config file wasn't being loaded on node start. --- cli/utils.go | 3 +++ config/config.go | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/utils.go b/cli/utils.go index 0f3fa0e565..8c1a40dc1f 100644 --- a/cli/utils.go +++ b/cli/utils.go @@ -99,6 +99,9 @@ func setStoreContext(cmd *cobra.Command, cfg *config.Config) error { // loadConfig loads the rootDir containing the configuration file, // otherwise warn about it and load a default configuration. func loadConfig(cfg *config.Config) error { + if err := cfg.LoadRootDirFromFlagOrDefault(); err != nil { + return err + } return cfg.LoadWithRootdir(cfg.ConfigFileExists()) } diff --git a/config/config.go b/config/config.go index c179fc5db3..22496d2240 100644 --- a/config/config.go +++ b/config/config.go @@ -130,10 +130,6 @@ func (cfg *Config) LoadWithRootdir(withRootdir bool) error { return err } - if err := cfg.LoadRootDirFromFlagOrDefault(); err != nil { - return err - } - if withRootdir { if err := cfg.v.ReadInConfig(); err != nil { return NewErrReadingConfigFile(err)