You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(lite): load dotenv files before server startup - #3618
The Lite distribution is built from cmd/server, but the server entrypoint did not load the dotenv file shipped with Lite packages. Starting WeKnora-lite directly therefore ignored .env.lite (and .env) before the container read DB_DRIVER, DB_PATH, JWT_SECRET, and other settings.
This change:
loads an explicitly configured ENV_FILE when present;
otherwise loads .env.lite first and .env second;
preserves the existing process environment over values from files;
documents the startup behavior for Lite deployments;
adds regression tests for precedence and explicit file selection.
Testing
CGO_ENABLED=0 go test ./internal/envfile -count=1
go vet ./internal/envfile
git diff --check
The full application test suite was not run locally because this Windows environment has no C compiler for the repository's CGO-bound PostgreSQL parser dependency; the targeted package tests pass.
Hi @lyingbug, following up on #3618. The latest CodeCC check is green. Please let me know if you would like any adjustments to the dotenv loading change or its tests.
#3618 fix(lite): load dotenv files before server startup(@tsumon)
Thanks @tsumon — I agree that directly running the Lite tarball should pick up its configuration without a separate shell source step. I have two concerns with the current loading policy:
cmd/server is also the standard backend's entry point, and envfile.Load() runs unconditionally (cmd/server/main.go:43-48). make dev-app already exports .env and .env.local, so their values remain authoritative. However, a standard binary built in the repo root with make build will now automatically read .env.lite too. With no corresponding process variables set, .env.lite takes precedence over .env, including DB_DRIVER=sqlite (internal/envfile/envfile.go:31-38).
For Lite, .env supplements .env.lite even when the latter exists. With files copied from the current templates, that imports REDIS_ADDR=redis:6379 and the Langfuse credentials/host. The Redis address selects the Redis/Asynq path despite STREAM_MANAGER_TYPE=memory (internal/container/container.go:438-460,750-771); the Langfuse keys also enable tracing (internal/tracing/langfuse/config.go:79-83).
Could you remove the automatic .env fallback, keep explicit ENV_FILE support and process-environment precedence, and scope automatic .env.lite loading to Lite builds? Looking beside the executable via os.Executable() is reasonable for the tarball, but that path change alone would still affect standard binaries built in the repo root. Please update the docs and regression tests for the chosen policy, including standard startup and Lite startup with both files present, and confirm that it fits the intended packaging flow.
I also noticed that dotenv loading happens after the logger's package initialization, so file-based LOG_LEVEL and LOG_PATH are not applied. Please call logger.ConfigureFromEnv() after loading, as the desktop entry point already does (internal/logger/logger.go:230-258; cmd/desktop/main.go:177-180).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3401.
The Lite distribution is built from
cmd/server, but the server entrypoint did not load the dotenv file shipped with Lite packages. StartingWeKnora-litedirectly therefore ignored.env.lite(and.env) before the container readDB_DRIVER,DB_PATH,JWT_SECRET, and other settings.This change:
ENV_FILEwhen present;.env.litefirst and.envsecond;Testing
CGO_ENABLED=0 go test ./internal/envfile -count=1go vet ./internal/envfilegit diff --checkThe full application test suite was not run locally because this Windows environment has no C compiler for the repository's CGO-bound PostgreSQL parser dependency; the targeted package tests pass.