If built locally, dicedb works for as long as the build cache in the tmp directory exists - it looks for a file called VERSION in the project root. Once cleared, or in the case of downloading from substitute server, the location of the VERSION file is invalid. Removing this code and instead providing them through the flag resolves this issue. diff --git a/config/config.go b/config/config.go index b358813..c408096 100644 --- a/config/config.go +++ b/config/config.go @@ -9,8 +9,6 @@ import ( "os" "path/filepath" "reflect" - "runtime" - "strings" "github.com/spf13/pflag" "github.com/spf13/viper" @@ -20,30 +18,6 @@ var ( DiceDBVersion = "-" ) -// init initializes the DiceDBVersion variable by reading the -// VERSION file from the project root. -// This function runs automatically when the package is imported. -func init() { - // Get the absolute path of the current file (config.go) - // using runtime reflection - _, currentFile, _, _ := runtime.Caller(0) //nolint:dogsled - - // Navigate up two directories from config.go to reach the project root - // (config.go is in the config/ directory, so we need to go up twice) - projectRoot := filepath.Dir(filepath.Dir(currentFile)) - - // Read the VERSION file from the project root - // This approach works regardless of where the program is executed from - version, err := os.ReadFile(filepath.Join(projectRoot, "VERSION")) - if err != nil { - slog.Error("could not read the version file", slog.String("error", err.Error())) - os.Exit(1) - } - - // Store the version string in the package-level DiceDBVersion variable - DiceDBVersion = strings.TrimSpace(string(version)) -} - var Config *DiceDBConfig type DiceDBConfig struct {