From a373c512e464cb1944531f1a4e09916dde3ab535 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Thu, 21 May 2026 15:13:18 +0100 Subject: [PATCH] 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. --- .changeset/bundle-skills-env.md | 5 +++++ packages/cli-v3/src/dev/devSession.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .changeset/bundle-skills-env.md diff --git a/.changeset/bundle-skills-env.md b/.changeset/bundle-skills-env.md new file mode 100644 index 00000000000..766f2a0371b --- /dev/null +++ b/.changeset/bundle-skills-env.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +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`. diff --git a/packages/cli-v3/src/dev/devSession.ts b/packages/cli-v3/src/dev/devSession.ts index 2d6645cd50c..cc801473ec8 100644 --- a/packages/cli-v3/src/dev/devSession.ts +++ b/packages/cli-v3/src/dev/devSession.ts @@ -121,6 +121,10 @@ export async function startDevSession({ // Built-in skill bundling — copies registered skill folders into // `.trigger/skills/{id}/` so `skill.local()` works at dev runtime. + // The indexer pass must match the main worker indexer's env (see + // devSupervisor.#getEnvVars) — otherwise task files that read + // CLI-injected vars (TRIGGER_API_URL, TRIGGER_SECRET_KEY) at module + // top level throw on import here while succeeding in the real worker. try { const buildManifestPath = join( workerDir?.path ?? destination.path, @@ -131,7 +135,11 @@ export async function startDevSession({ buildManifest, buildManifestPath, workingDir: rawConfig.workingDir, - env: process.env, + env: { + ...process.env, + TRIGGER_API_URL: client.apiURL, + TRIGGER_SECRET_KEY: client.accessToken ?? undefined, + }, logger: buildContext.logger, }); buildManifest = skillsResult.buildManifest;