Search code examples
dbt

dbt: check what packages are installed


Is there a way to check what packages are installed? I would expect something like dbt list packages?

The context is:

  • Until I run dbt deps the content of packages.yml gives me nothing. And there are some situations when the models could be triggered without running dbt deps
  • I would like to check the packages in runtime

I searched over google and dbt --help but I didn't find anything.


Solution

  • Recently I had the opportunity to work with packages closely and I published an article The Practical Guide to Utilizing DBT Packages for Data Transformation which explains dbt packages and its underhood

    Here is the quote:

    To verify that a package is installed in your dbt project, you can check the packages.yml file and run the dbt deps command.

    1. Check the packages.yml file: This file lists all of the packages that are installed in your dbt project. Look for the name of the package you want to verify. If it is listed in the packages list, then it is installed.

    2. Run the dbt deps command:

      1. This command will show you a list of all of the packages that are installed in your dbt project. Look for the name of the package you want to verify. If it is listed, then it is installed.
      2. In the root dbt project dir, you observe a new dir dbt_modules/ which contains the compiled packages that are ready to be used. NOTE: dir dbt_modules/ has to be added to .gitignore.
    >>> tree -L 1 .
    .
    ├── data
    ├── dbt_modules
    ├── dbt_project.yml
    ├── macros
    ├── models
    ├── packages
    ├── packages.yml
    ├── profiles.yml
    ├── snapshots
    └── target
    

    If your packages.yml file contains package that is not installed then you would not be able to run any dbt command:

    >>> dbt list
    Encountered an error:
    Compilation Error
      dbt found 1 package(s) specified in packages.yml, but only 0 package(s) installed in dbt_modules. Run dbt deps to install package dependencies.
    

    So this is our guarantee that in runtime we would not have any issues related to the package installation.