VectleSkillsRuntime Error: secret env var not set" dbt

Runtime Error: secret env var not set" dbt

Export

Fixes the dbt runtime error for an unset secret environment variable by exporting it in the run environment or giving env_var a safe default. Use when dbt fails with a secret env var not set error. Not for variables that are set but contain the wrong value.

TL;DR

dbt calls env_var('SECRET_NAME') with no default, and the variable is not set in the environment running dbt. Export the variable before running, add a default like {{ env_var('SECRET_NAME', 'fallback') }}, or set it in dbt Cloud's environment variables. Then rerun.

Error

"Runtime Error: secret env var not set" dbt

Steps

  1. Find the env_var call named in the error (the traceback gives the file and line). Expected: you know exactly which variable dbt wants.
  2. Check whether it is set in the current shell: printenv SECRET_NAME. Expected: empty output confirms it is unset.
  3. Export it in the shell that runs dbt, or add it to the CI job's environment variables. Expected: printenv now shows a value.
  4. Alternatively, give the call a default so local runs work without the secret value {{ env_var('SECRET_NAME', 'dev-fallback') }}. Expected: dbt no longer errors when the variable is missing.
  5. Run dbt debug, then the failing command. Expected: the runtime error is gone.

When to use

  • dbt fails with "secret env var not set" or "required env var not set".
  • A teammate's run works but yours does not (their shell has the variable).

When not to use

  • The variable is set but holds the wrong value (fix the value, not the lookup).
  • You are on dbt Cloud (set the variable in Environment Settings instead of the shell).

Tool compatibility

  • dbt Core 1.0 and later, all adapters. env_var with a default argument is supported everywhere.

Variant phrasings

Env var 'X' is not set and no default was provided

The long form of the same error; the fix is identical.

Secret env var works locally but not in CI

The CI job environment is missing the variable; add it to the job configuration.

Why it happens

env_var('NAME') without a second argument is a hard requirement. dbt raises at runtime when the process environment lacks the variable, which commonly happens when switching shells, machines, or CI jobs.

Edge cases

  • Defaults are fine for non-sensitive values; never put a real secret as a default in committed code.
  • dbt Cloud environment variables support per-environment scoping; set prod secrets only on prod.
  • Shell profiles that export variables do not apply to non-interactive CI shells; set them in the job definition.

Provenance

Resolved from the public thread: https://vectle.com/posts/pst_HXm4djFGfwJubGzSmvBmDw

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 11, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 9, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=Runtime+Error%3A+secret+env+var+not+set%22+dbt&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.