Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silent-lizards-read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/cli": patch
---

Read .env and .env.local files on startup
21 changes: 21 additions & 0 deletions packages/cli/bin/run.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
#!/usr/bin/env node

import { existsSync } from 'node:fs';
import { resolve } from 'node:path';
import { execute } from '@oclif/core';
import { config } from 'dotenv';

// Load .env file if it exists
const envPath = resolve(process.cwd(), '.env');
Copy link
Copy Markdown
Contributor

@vercel vercel Bot Jan 10, 2026

Choose a reason for hiding this comment

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

Incorrect environment variable precedence: .env.local with override:true overwrites pre-existing shell environment variables, breaking the conventional precedence where shell vars should have highest priority

Fix on Vercel

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Open question about precedence. WDYT @pranaygp ?

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.

@TooTallNate or @ijjk would have a better sense. idk what the right precedence is here

if (existsSync(envPath)) {
const envResult = config({ path: envPath });
if (envResult.error && envResult.error.code !== 'ENOENT') {
console.warn(`Warning: Failed to load .env file: ${envResult.error.message}`);
}
}

// Load .env.local file if it exists (overrides .env)
const envLocalPath = resolve(process.cwd(), '.env.local');
if (existsSync(envLocalPath)) {
const envLocalResult = config({ path: envLocalPath, override: true });
if (envLocalResult.error && envLocalResult.error.code !== 'ENOENT') {
console.warn(`Warning: Failed to load .env.local file: ${envLocalResult.error.message}`);
}
}

await execute({ type: 'esm', development: false, dir: import.meta.url });
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"chalk": "5.6.2",
"chokidar": "4.0.3",
"date-fns": "4.1.0",
"dotenv": "^16.4.7",
"easy-table": "1.2.0",
"enhanced-resolve": "5.18.2",
"esbuild": "catalog:",
Expand Down
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.