0
0
DbtHow-ToBeginner ยท 3 min read

How to Install a Package in dbt: Simple Steps

To install a package in dbt, add the package details to your packages.yml file in your project folder, then run dbt deps in your terminal. This command downloads and installs the package so you can use it in your dbt project.
๐Ÿ“

Syntax

To install a package in dbt, you use the packages.yml file to list the packages you want. Then you run a command to download them.

  • packages.yml: A YAML file where you specify package names and versions.
  • dbt deps: A terminal command that downloads and installs the packages listed in packages.yml.
yaml
packages:
  - package: dbt-labs/dbt_utils
    version: 0.8.6
๐Ÿ’ป

Example

This example shows how to install the popular dbt_utils package. First, add it to packages.yml. Then run dbt deps to install.

yaml and shell
# packages.yml
packages:
  - package: dbt-labs/dbt_utils
    version: 0.8.6

# Terminal command to run in your project folder
dbt deps
Output
Running with dbt=1.4.6 Installing dbt-labs/dbt_utils Installed dbt-labs/dbt_utils 0.8.6
โš ๏ธ

Common Pitfalls

Common mistakes when installing packages in dbt include:

  • Not creating or updating the packages.yml file correctly.
  • Forgetting to run dbt deps after editing packages.yml.
  • Using incorrect package names or versions that do not exist.
  • Running dbt deps outside the project folder.

Always check your YAML syntax and run dbt deps in the right folder.

yaml
Wrong packages.yml example:
packages:
  - package: dbt-labs/dbt_utils
    version: 999.999.999  # Version does not exist

Right packages.yml example:
packages:
  - package: dbt-labs/dbt_utils
    version: 0.8.6
๐Ÿ“Š

Quick Reference

StepCommand/FileDescription
1packages.ymlAdd package name and version here
2dbt depsRun this command to install packages
3dbt runUse installed packages in your models
โœ…

Key Takeaways

Add packages to the packages.yml file to specify what to install.
Run dbt deps in your project folder to download and install packages.
Check package names and versions carefully to avoid errors.
Always run dbt deps after changing packages.yml to update packages.
Use installed packages in your dbt models after installation.