Skip to content

Instantly share code, notes, and snippets.

@jeremyyeo
Last active February 26, 2022 07:44
Show Gist options
  • Save jeremyyeo/dd3df9b6dde44f665b63a95b765ab893 to your computer and use it in GitHub Desktop.
Save jeremyyeo/dd3df9b6dde44f665b63a95b765ab893 to your computer and use it in GitHub Desktop.
Installing really old dbt versions #dbt

Installing really old dbt versions

-!  🚨                                          WARNING                                          🚨  !-
This is not for the faint of heart - and you should avoid using old versions if possible.

Preamble

If you have dbt installed globally on your machine (e.g. via brew) - you probably want to remove it (e.g. brew remove dbt).

The following steps were tested on macOS 12.1 (non M1) with Python 3.8.7.

Steps

  1. Clone the dbt-core repo.
mkdir ~/src && cd ~/src
git clone https://github.com/dbt-labs/dbt-core.git

I'm cloning into my home directorys' src folder but you can choose to clone this somewhere else.

  1. Checkout the 0.14.latest branch.
cd ~/src/dbt-core
git checkout 0.14.latest
  1. Remove the psycopg2 requirements from the postgres and redshift plugin setup.py files. We're going to install the psycopg2-binary package instead.
sed -i.bak '33d' plugins/postgres/setup.py
sed -i.bak '34d' plugins/redshift/setup.py

I'm using sed to delete line 33 in the plugins/postgres/setup.py file and line 34 in the plugins/redshift/setup.py file but you can just open those files up in a text editor and delete them instead.

  1. We're ready to install dbt with Python's pip.

Check that we have the right Python version (this will not be covered by this guide - you can try other Python versions but I can't guarantee that it will work).

python --version
Python 3.8.7

Create a Python virtual environment (and then activate it) to isolate our installation.

python -m venv venv
source venv/bin/activate

I'm creating a virtual environment with the name venv but you can choose to call it whatever you want (e.g. venv_dbt_0.14).

Update pip.

python -m pip install --upgrade pip

Install psycopg2-binary, the dbt cli application, and specific versions of supporting packages.

pip install psycopg2-binary
pip install -r requirements.txt
pip install Jinja2==2.10.1
pip install MarkupSafe==2.0.1

Check your installed dbt version.

dbt --version
installed version: 0.14.4
   latest version: 1.0.0

Your version of dbt is out of date! You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
  1. When you no longer want to be in this virtual environment where dbt 0.14 is available as a cli application, simply deactivate it (and reactivate via source it if you do - see above).
deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment