Skip to content

fix: make local dev environment work after a fresh clone#392

Open
andygrunwald wants to merge 6 commits into
useplunk:nextfrom
andygrunwald:andygrunwald/local-dev-env-setup-fixes
Open

fix: make local dev environment work after a fresh clone#392
andygrunwald wants to merge 6 commits into
useplunk:nextfrom
andygrunwald:andygrunwald/local-dev-env-setup-fixes

Conversation

@andygrunwald
Copy link
Copy Markdown
Contributor

Description

Local dev setup was broken in three small but interlocking ways after a fresh clone.
Following the guide in CONTRIBUTING.md wasn't enough.

  1. yarn workspace @plunk/db migrate:dev could not find DIRECT_DATABASE_URL. The script runs Prisma from packages/db/, where no .env exists (only .env.example). Prisma reads connection details from process.env relative to its CWD, so migrations silently failed unless the contributor knew to also create packages/db/.env. Fix: wrap the script with dotenv-cli -e ../../apps/api/.env, reusing the API's env file (already loaded by apps/api/src/app/constants.ts). One env file now serves both the API and DB migrations.

  2. yarn workspace api dev:server refused to boot from a clean cp apps/api/.env.example apps/api/.env. The env validator throws on empty AWS_SES_ACCESS_KEY_ID /
    AWS_SES_SECRET_ACCESS_KEY. Fix: seed harmless foo / bar placeholders so the server starts. Contributors who want to actually send mail still replace these with real keys.

  3. CONTRIBUTING.md skipped the apps/api/.env step entirely and used a <repo-url> / cd app placeholder. Fix: use the real repo URL/dir, add the missing copy step, and document the AWS SES dummies so they don't look like a bug.

Type of Change

  • fix: Bug fix (PATCH version bump)
  • docs: Documentation update (no version bump)

Testing

Manual end-to-end on a clean checkout:

Following CONTRIBUTING.md.

Checklist

  • PR title follows conventional commits format
  • Code builds successfully
  • Tests pass locally
  • Documentation updated (CONTRIBUTING.md reflects the new flow)

Related Issues

None

andygrunwald and others added 4 commits May 24, 2026 12:12
The `migrate:dev` script runs Prisma from packages/db, where no .env
file exists (only .env.example). Prisma reads its DATABASE_URL and
DIRECT_DATABASE_URL from process.env at the current working directory,
so the command was failing to find connection details and could not run
migrations without the developer also creating a duplicate .env inside
packages/db.

Wrap the command with dotenv-cli pointing at ../../apps/api/.env so a
single env file (the API's own .env, already loaded by
apps/api/src/app/constants.ts) serves both the API and DB migrations in
local development.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The api-server's env validator throws on empty AWS_SES_ACCESS_KEY_ID or
AWS_SES_SECRET_ACCESS_KEY, which prevents new contributors from booting
the server out of the box after a plain `cp apps/api/.env.example
apps/api/.env`.

Seed harmless placeholder values (foo / bar) so the server starts
without further configuration. Contributors who actually want to send
mail still need to replace these with real keys; the placeholders only
satisfy the boot-time presence check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
New contributors hit two snags when following the existing instructions:

1. The clone example used a `<repo-url>` placeholder and an `app`
   directory name that doesn't match the actual repo, so the rest of the
   commands silently failed for anyone copy-pasting.
2. There was no instruction to copy `apps/api/.env.example` to
   `apps/api/.env`, which is now required for both the API and the DB
   migrations (see the migrate:dev wrapper).

Replace the placeholder with the real repo URL, add the missing
`apps/api/.env` copy step, and note that AWS_SES_ACCESS_KEY_ID and
AWS_SES_SECRET_ACCESS_KEY must be non-empty for the server to start
(the dummies in .env.example are intentional).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The instruction to `cp .env.example .env` referenced a root-level
.env.example that does not exist in the repo (only `.env.self-host.example`
sits at the root, and that one is for self-hosting, not local dev). After
the previous commit's `cp apps/api/.env.example apps/api/.env` step, the
remaining root copy was both invalid and confusing.

Remove it and clarify the follow-up comment to point at apps/api/.env
specifically, so contributors aren't left wondering which .env to edit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@driaug
Copy link
Copy Markdown
Member

driaug commented May 24, 2026

I would prefer to keep the split .env file for the prisma schema and API, do you agree?

The other changes are good.

@andygrunwald
Copy link
Copy Markdown
Contributor Author

@driaug I just figured out the existence of packages/db/.env.example.
I reverted the dotenv change in fb2b691, adjusted CONTRIBUTING.md and re-tested it again.

This is now the proper guide to setup a local dev (at least for new users).

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.

2 participants