Prakash Dutta
Prakash Dutta

Reputation: 91

"dbt deps" from local repository

Is it allowed to create local dbt deps repository so that "dbt deps" command should download libraries from local repository?

N.B: Our client is not interested to connect to external network.

Upvotes: 1

Views: 4201

Answers (1)

Anders Swanson
Anders Swanson

Reputation: 3961

Yes this is possible, provided that the repositories have already been locally cloned or copied.

dbt docs's page on Packages tells you exactly how to do this

Packages that you have stored locally can be installed by specifying the path to the project, like so:

packages:
  - local: /opt/dbt/redshift # use a local path

Local packages should only be used for specific situations, for example, when testing local changes to a package.

Note: I think it is worth re-iterating the caveat given in the docs. You will now own downloading the cloning the correct versions of the packages along with the ongoing work of keeping the packages up-to-date.

As for how this works in practice. Consider the following example:

  • /Users/michelle/repos/my_dbt_project where my dbt project lives (that contains dbt_project.yml and packages.yml
  • /Users/michelle/repos/dbt_utils the location where I previously cloned the dbt-utils repo

In this example my packages.yml should look like

packages:
  - local: /Users/michelle/repos/dbt_utils # use a local path

Please note that the external package does not live within my dbt project directory, but outside of it. While it should work to have it within the repo, this is not best practice. This external package development article goes even further in-depth.

Upvotes: 5

Related Questions