Setup your pgvectorscale developer environment
You build pgvectorscale from source, then integrate the extension into each database in your PostgreSQL environment.
Setup your pgvectorscale developer environment
Section titled “Setup your pgvectorscale developer environment”You build pgvectorscale from source, then integrate the extension into each database in your PostgreSQL environment.
pgvectorscale prerequisites
Section titled “pgvectorscale prerequisites”To create a pgvectorscale developer environment, you need the following on your local machine:
-
Development packages:
sudo apt-get install make gcc pkg-config clang postgresql-server-dev-16 libssl-dev -
Rust:
Terminal window curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Build and install pgvectorscale on your database
Section titled “Build and install pgvectorscale on your database”-
In Terminal, clone this repository and switch to the extension subdirectory:
Terminal window git clone https://github.com/timescale/pgvectorscale && \cd pgvectorscale/pgvectorscale -
Install Cargo-pgrx:
Terminal window cargo install --locked cargo-pgrx --version $(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "pgrx") | .version')You must reinstall cargo-pgrx whenever you update Rust, cargo-pgrx must be built with the same compiler as pgvectorscale.
-
Initialize the pgrx development environment:
cargo pgrx init --pg16 pg_config-
Build pgvectorscale:
Terminal window cargo pgrx install --releaseIf the destination folder requires elevated permissions, use the
--sudoflag:Terminal window cargo pgrx install --sudo --release -
Connect to the database:
Terminal window psql -d "postgres://<username>@<password>:<port>/<database-name>" -
Add pgvectorscale to your database:
CREATE EXTENSION IF NOT EXISTS vectorscale CASCADE;
Troubleshooting
Section titled “Troubleshooting”MacOS: fatal error: ‘stdio.h’ file not found
Section titled “MacOS: fatal error: ‘stdio.h’ file not found”Make sure you have the command line tools:
xcode-select --installIf the error persists try setting explicitly the SDKROOT environment
variable:
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)Make sure the variable was set:
$ env | grep SDKROOTSDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdkPermission denied while installing the extension artifacts
Section titled “Permission denied while installing the extension artifacts”If the PostgreSQL directory where the extension needs to be installed requires
elevated permissions (for example, when using MacOS PostgreSQL that installs in the
/Applications folder, or when installing from a package manager that uses a system
directory), you need to use the pgrx --sudo flag:
cargo pgrx install --sudo --release