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;