Skip to content

feat(cli): require --env-path instead of auto-loading .env.local#3098

Open
jorgemoya wants to merge 4 commits into
canaryfrom
jorgemoya/ltrac-1091-reconsider-automatic-env-file-loading-envlocal-auto-read-but
Open

feat(cli): require --env-path instead of auto-loading .env.local#3098
jorgemoya wants to merge 4 commits into
canaryfrom
jorgemoya/ltrac-1091-reconsider-automatic-env-file-loading-envlocal-auto-read-but

Conversation

@jorgemoya

Copy link
Copy Markdown
Contributor

Linear: LTRAC-1091

What/Why?

The CLI auto-loaded .env.local from cwd but not .env, an inconsistent bit of magic that surprised users. Per sign-off, this drops automatic env-file loading entirely: env files are now loaded only when passed explicitly via --env-path. This removes the .env vs .env.local asymmetry and makes env resolution explicit and predictable. Help text is updated to match.

Testing

  • index.spec.ts (7 tests) covers no-auto-load without --env-path and correct loading with --env-path.
  • typecheck and lint pass.

Migration

Breaking behavior change. Users who relied on the auto-loaded .env.local must now pass it explicitly:

catalyst deploy --env-path .env.local

(or the appropriate path, e.g. --env-path ./core/.env.local).

The CLI auto-loaded .env.local from cwd but not .env, an inconsistent bit of
magic that surprised users. Drop automatic env-file loading entirely: env
files are now loaded only when passed explicitly via --env-path. This removes
the .env vs .env.local asymmetry and makes env resolution explicit and
predictable. Help text is updated to match.

BREAKING: users who relied on auto-loaded .env.local must now pass
--env-path .env.local (or the appropriate path).

Refs LTRAC-1091
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c5823d9

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

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst Minor

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

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
catalyst Ready Ready Preview, Comment Jul 10, 2026 8:42pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Report

Comparing against baseline from 8d9f9a9 (2026-07-10).

No bundle size changes detected.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Unlighthouse Performance Comparison — Vercel

Comparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores.

Summary Score

Aggregate score across all categories as reported by Unlighthouse.

Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Score 90 93 92 94

Category Scores

Category Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Performance 75 86 73 83
Accessibility 95 98 95 91
Best Practices 100 100 100 85
SEO 88 88 88 100

Core Web Vitals

Metric Prod Desktop Prod Mobile Preview Desktop Preview Mobile
LCP 4.0 s 4.1 s 4.4 s 0.9 s
CLS 0.037 0.001 0.037 0.344
FCP 1.1 s 1.2 s 1.1 s 0.9 s
TBT 0 ms 0 ms 0 ms 0 ms
Max Potential FID 50 ms 40 ms 50 ms 20 ms
Time to Interactive 4.0 s 4.1 s 4.5 s 0.9 s

Full Unlighthouse report →

The changeset body was hard-wrapped mid-paragraph, which rendered as
pre-split lines in the changelog. Put each paragraph on a single line to
match the repo's changeset style.

Refs LTRAC-1091
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The top-level description restated that env files aren't auto-loaded, which
is already covered by the --env-path option help. Keep the (now accurate)
configuration-priority line and let --env-path document the behavior.

Refs LTRAC-1091
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jorgemoya jorgemoya marked this pull request as ready for review July 10, 2026 17:57
@jorgemoya jorgemoya requested a review from a team as a code owner July 10, 2026 17:57

@mfaris9 mfaris9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Instead of removing env-file auto-loading globally, restrict it to the only
commands that need storefront env vars: `build` and `deploy`. Both now
auto-load `.env.local` then `.env` from the current directory (`.env.local`
wins; neither overrides the real environment), or an explicit `--env-path`.
The global `--env-path` option is removed so no other command is affected by
on-disk env files. The env is loaded before the build runs so the build child
process (and any pre-build checks) can see the variables.

Adds a shared `loadBuildEnv` helper and moves `--env-path` to a per-command
option via `envPathOption`.

Refs LTRAC-1091
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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