Skip to content

Commit a373c51

Browse files
committed
fix(cli): match bundleSkills indexer env with main worker indexer
The bundleSkills indexer pass runs a child process to import every task file and read its skill registrations. It was passed `env: process.env`, but the main worker indexer (devSupervisor.#getEnvVars) injects TRIGGER_API_URL and TRIGGER_SECRET_KEY from the active CLI profile, not from .env. So any task file that reads process.env.TRIGGER_API_URL (or related CLI-injected vars) at module top level imported fine in the real worker but threw in the bundleSkills indexer, surfacing as a spurious [bundleSkills] skill discovery failed, skipping skill bundling: Failed to import some task files warning on every dev rebuild for any project that doesn't duplicate TRIGGER_API_URL into its .env. Fix: thread TRIGGER_API_URL + TRIGGER_SECRET_KEY from the client into the bundleSkills env so the two indexer passes see the same environment.
1 parent 9ff410b commit a373c51

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.changeset/bundle-skills-env.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Pass `TRIGGER_API_URL` and `TRIGGER_SECRET_KEY` to the `bundleSkills` indexer pass in dev so it matches the env the main worker indexer gets. Without this, task files that read CLI-injected env vars at module top level threw on import in the skill-discovery pass while succeeding in the real worker, surfacing as a spurious `[bundleSkills] skill discovery failed, skipping skill bundling: Failed to import some task files` warning on every dev rebuild for any project that doesn't duplicate `TRIGGER_API_URL` into its `.env`.

packages/cli-v3/src/dev/devSession.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ export async function startDevSession({
121121

122122
// Built-in skill bundling — copies registered skill folders into
123123
// `.trigger/skills/{id}/` so `skill.local()` works at dev runtime.
124+
// The indexer pass must match the main worker indexer's env (see
125+
// devSupervisor.#getEnvVars) — otherwise task files that read
126+
// CLI-injected vars (TRIGGER_API_URL, TRIGGER_SECRET_KEY) at module
127+
// top level throw on import here while succeeding in the real worker.
124128
try {
125129
const buildManifestPath = join(
126130
workerDir?.path ?? destination.path,
@@ -131,7 +135,11 @@ export async function startDevSession({
131135
buildManifest,
132136
buildManifestPath,
133137
workingDir: rawConfig.workingDir,
134-
env: process.env,
138+
env: {
139+
...process.env,
140+
TRIGGER_API_URL: client.apiURL,
141+
TRIGGER_SECRET_KEY: client.accessToken ?? undefined,
142+
},
135143
logger: buildContext.logger,
136144
});
137145
buildManifest = skillsResult.buildManifest;

0 commit comments

Comments
 (0)