Skip to content
Latchkey

WordPress Bedrock "WP_HOME" not defined (.env missing) in CI

Bedrock loads configuration from a .env file and validates that required keys exist. .env is gitignored, so a fresh CI checkout has none, and the Dotenv validator throws because WP_HOME and other required variables are undefined.

What this error means

Bootstrapping WordPress under Bedrock fails with "Dotenv\Exception\ValidationException: One or more environment variables failed assertions: WP_HOME is missing, DB_NAME is missing".

Bedrock
PHP Fatal error:  Uncaught Dotenv\Exception\ValidationException: One or more
environment variables failed assertions: WP_HOME is missing, WP_SITEURL is missing,
DB_NAME is missing in /var/www/vendor/vlucas/phpdotenv/src/Validator.php

Common causes

The .env file is gitignored and absent in CI

Bedrock keeps secrets out of git, so the runner checkout has no .env, and Dotenv::required() fails for every expected key.

Required keys are set but not exported to the process

Variables exist in the workflow but were not written to .env or exported, so Bedrock's validator does not see them.

How to fix it

Generate .env from CI secrets

  1. Define WP_HOME, WP_SITEURL, and DB_* as CI secrets or env.
  2. Write them into a .env at the project root before any wp call.
  3. Re-run so Bedrock's Dotenv validation passes.
Terminal
cat > .env <<'EOF'
WP_HOME=http://localhost
WP_SITEURL=${WP_HOME}/wp
DB_NAME=wordpress
DB_USER=root
DB_PASSWORD=root
DB_HOST=127.0.0.1
EOF

Export the variables to the environment instead

phpdotenv reads existing environment variables; set them in the step env so the validator finds them without a file.

.github/workflows/ci.yml
env:
  WP_HOME: http://localhost
  WP_SITEURL: http://localhost/wp
  DB_NAME: wordpress

How to prevent it

  • Render .env from secrets at the start of every Bedrock CI job.
  • Keep the required-key list in sync between config/ and CI.
  • Never commit .env; provide it per-environment in CI.

Frequently asked questions

What causes "Bedrock ".env" / WP_HOME missing"?
Bedrock keeps secrets out of git, so the runner checkout has no .env, and Dotenv::required() fails for every expected key.
How do I fix Bedrock ".env" / WP_HOME missing?
Generate .env from CI secrets

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card