1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-12 18:10:47 +02:00
guix/gnu/packages/patches/dicedb-remove-init-from-config-subpkg.patch
Ashvith Shetty bff04df003
gnu: Add dicedb.
* gnu/packages/databases.scm (dicedb): New variable.
* gnu/packages/patches/dicedb-remove-init-from-config-subpkg.patch:
New file.
* gnu/local.mk (dist_patch_DATA): Register patch.

Change-Id: Id5c97d254c35301181593b42c96a83a1ef843131
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2025-05-27 15:14:11 +02:00

50 lines
1.7 KiB
Diff

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 {