Skip to content

fix(db): read ASTRO_DATABASE_FILE from .env files correctly#15747

Open
7836246 wants to merge 2 commits intowithastro:mainfrom
7836246:fix/issue-15607-db-env-var
Open

fix(db): read ASTRO_DATABASE_FILE from .env files correctly#15747
7836246 wants to merge 2 commits intowithastro:mainfrom
7836246:fix/issue-15607-db-env-var

Conversation

@7836246
Copy link

@7836246 7836246 commented Mar 4, 2026

Fixes #15607

The databaseFileEnvDefined() function used Vite's loadEnv('', process.cwd()) which defaults to only loading VITE_-prefixed environment variables. This meant ASTRO_DATABASE_FILE set in .env files was never detected, causing a false error during astro build.

The fix reuses the existing getAstroEnv() utility which correctly passes the 'ASTRO_' prefix to loadEnv(), consistent with how other parts of the @astrojs/db package load environment variables.

Changes

Testing

Docs

Fixes withastro#15607

The `databaseFileEnvDefined()` function used Vite's `loadEnv('', process.cwd())`
which defaults to only loading `VITE_`-prefixed environment variables.
This meant `ASTRO_DATABASE_FILE` set in `.env` files was never detected,
causing a false error during `astro build`.

The fix reuses the existing `getAstroEnv()` utility which correctly passes
the `'ASTRO_'` prefix to `loadEnv()`, consistent with how other parts of
the `@astrojs/db` package load environment variables.
@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: 7f46ecc

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Could not build with ASTRO_DATABASE_FILE env var

1 participant