Skip to content

Config::init fails to find .env when running app from workspace root during framework development #34

@msaifmfz

Description

@msaifmfz

Context: This affects framework development only (the monorepo workspace), not end users who scaffold via kit new myapp && cd myapp && kit serve

When developing the framework and running the example app via ./dev.sh (or cargo run -p app from the workspace root), the app panics:

thread 'main' panicked at framework/src/app.rs:297:53:
DATABASE_URL must be set: NotPresent

Root cause: Config::init(Path::new(".")) in framework/src/app.rs:218 loads .env relative to CWD.
dev.sh runs cargo run -p app from the workspace root (kit/), but .env lives in kit/app/.
So dotenvy never finds it.

Current workaround: cd app before running, or wrap in a subshell: (cd app && cargo run -p app)

Suggested fix: Config::init could resolve the project root using CARGO_MANIFEST_DIR or similar, rather than assuming CWD == project root. This would make it robust for both end users and workspace development.

Affected files:

  • framework/src/app.rs:218 — Config::init(Path::new("."))
  • framework/src/config/env.rs:71load_dotenv(project_root) receives . as-is

I'm happy to submit a PR :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions