Home / Data Platform / dbt & Quality

Data PlatformTroubleshootingBeginner

dbt deps failing: package version conflicts, private Git packages and package-lock.yml surprises

Fix dbt deps errors in CI and on laptops. Covers unsatisfiable version ranges, require-dbt-version mismatches, private Git authentication and lock files that quietly pin old package versions.

Deepak Bhardwaj7 min read

Applies todbt Core 1.7 and later (package-lock.yml, --lock, --upgrade, --add-package) and dbt Cloud. Older versions have no lock file

Symptom

A dbt job fails before any model runs, at the dbt deps step or at the first command after it. Typical messages:

  • Version error for package dbt-labs/dbt_utils: Could not find a satisfactory version from options: [...]
  • This version of dbt is not supported with the '<package>' package (the package's require-dbt-version excludes your dbt version)
  • Error checking out spec='...' or fatal: could not read Username for 'https://github.com' for a Git package
  • Compilation Error ... 'dbt_utils' is undefined because dbt deps was never run, or it installed somewhere the project doesn't look
  • CI works but a laptop doesn't, or the other way round, because the two use different package-lock.yml files

These failures stop the whole project, so fix deps first and rerun the job.

Quick checks

dbt --version                 # dbt Core and adapter versions
cat packages.yml              # or dependencies.yml
cat package-lock.yml          # what is actually pinned
ls dbt_packages/              # what is actually installed
dbt deps                      # read the first error line carefully
Symptom Likely cause Fix
Could not find a satisfactory version Two packages need incompatible versions of a shared dependency (often dbt_utils) Widen your range, or upgrade the package with the stricter pin
not supported with the '<package>' package Package's require-dbt-version excludes your dbt version Pin an older package release, or upgrade dbt
Git auth errors in CI only No credential in the runner, or a token that expired Use an env var token in the Git URL
'dbt_utils' is undefined deps not run, or wrong packages-install-path Run dbt deps in the job, check dbt_project.yml
Package didn't upgrade after editing nothing package-lock.yml still pins the old version dbt deps --upgrade and commit the lock file
Different versions in CI and locally Lock file not committed, or ignored Commit package-lock.yml

Fix 1: version conflicts

dbt resolves Hub packages and their dependencies against a single version range per package. A conflict means two packages want different, non-overlapping versions of the same thing.

# packages.yml
packages:
  - package: dbt-labs/dbt_utils
    version: [">=1.1.0", "<2.0.0"]     # a range, not a single pin
  - package: dbt-labs/codegen
    version: [">=0.12.0", "<0.14.0"]

Steps:

  1. Read the error. It lists the versions dbt found for the conflicting package.
  2. Check each package's own packages.yml on the Hub or in its Git repository to see what it requires.
  3. Change your own pins to ranges instead of exact versions, so that dbt can find an overlap.
  4. If there is still no overlap, upgrade the package that has the older requirement, or drop it.

To add or change a Hub package from the command line (dbt 1.7+):

dbt deps --add-package dbt-labs/dbt_utils@1.1.1

This edits packages.yml and installs the package. Check the change into Git like any other edit.

Tip

Pre-release Hub versions are ignored unless you set install-prerelease: true on that package. Use this only to test a fix you are waiting on, not in production.

Fix 2: require-dbt-version mismatches

Packages declare which dbt versions they support. After a dbt upgrade (or a downgrade in a pinned CI image), an older package may refuse to load.

dbt --version
# Compare with require-dbt-version in dbt_packages/<package>/dbt_project.yml
grep -A3 require-dbt-version dbt_packages/*/dbt_project.yml

Options, in order of preference:

  1. Upgrade the package to a release that supports your dbt version.
  2. Pin the dbt version in CI to match what the project was tested with (for example in requirements.txt).
  3. As a last resort, skip the require-dbt-version check with the --no-version-check flag, then plan the upgrade.
dbt build --no-version-check     # temporary, document why

Warning

--no-version-check hides real incompatibilities. Macros can fail at run time or, worse, generate different SQL. Use it to get through an incident, not as a permanent setting.

Fix 3: private Git packages

Hub packages download over HTTPS from the dbt package hub. Git packages are cloned with the runner's git, using the runner's credentials.

packages:
  - git: "https://{{ env_var('DBT_ENV_SECRET_GIT_CREDENTIAL') }}@github.com/acme/dbt-shared-macros.git"
    revision: v2.3.0          # a tag or commit SHA, not a branch
    subdirectory: dbt          # only if the dbt project isn't at the repo root

Points that cause most failures:

  • Env var name. Variables that start with DBT_ENV_SECRET_ are scrubbed from logs. Make sure the CI secret is exported under that exact name in the step that runs dbt deps.
  • Expired or under-scoped token. The token needs read access to that repository. Test it outside dbt with git ls-remote https://<token>@github.com/acme/dbt-shared-macros.git.
  • Branch revisions. revision: main makes builds non-repeatable and dbt warns about it. Use a tag or a commit SHA.
  • SSH URLs in CI. git@github.com:... needs an SSH key and known_hosts on the runner. HTTPS with a token is usually easier in pipelines.
  • Network. Locked-down runners must reach the dbt Hub and your Git host. Check proxy settings (HTTPS_PROXY) if deps hangs and then times out.

For code in the same repository, use a local package instead of Git:

packages:
  - local: ../shared_macros

Fix 4: package-lock.yml behaviour

Since dbt 1.7, dbt deps writes package-lock.yml with the exact resolved versions (and a hash of the package config). Later runs install what the lock file says, not the newest version that matches your range.

You want to Run
Install exactly what's locked dbt deps
Pick up a change you made to packages.yml dbt deps (it detects the changed config and re-resolves)
Upgrade everything within your ranges dbt deps --upgrade
Update the lock file without installing dbt deps --lock
dbt deps --upgrade
git diff package-lock.yml       # review what moved
git add packages.yml package-lock.yml
git commit -m "Upgrade dbt packages"

Caution

If package-lock.yml is in .gitignore, or every CI run deletes it, each build resolves versions again. A new package release can then change the generated SQL in production without a code change. Commit the lock file and upgrade on purpose.

Fix 5: packages installed but not found

# dbt_project.yml
packages-install-path: dbt_packages     # default; older projects used dbt_modules
clean-targets: ["target", "dbt_packages"]
  • Each fresh CI container has no packages. Run dbt deps in the same job, before dbt build, unless you cache dbt_packages/ on purpose.
  • In dbt 1.6 and later you can declare packages in dependencies.yml instead of packages.yml, but not in both. Pick one file.
  • If you suspect stale files, run dbt clean followed by dbt deps.

Prevent it next time

  • Use version ranges for Hub packages and commit package-lock.yml. Upgrade with dbt deps --upgrade in a pull request, never by accident.
  • Pin dbt Core and the adapter in requirements.txt or your container image so that require-dbt-version checks are predictable.
  • Pin Git packages to tags or SHAs, and store the token as a DBT_ENV_SECRET_ variable with an owner and an expiry reminder.
  • Add a CI step that runs dbt deps followed by dbt parse. Package problems then fail in seconds on the pull request, not at 02:00 in the production job.
  • Review package changelogs before upgrading dbt_utils or other macro packages your models depend on.