Postgresql plugin for asdf version manager, using prebuilt binaries.
Configuring from source is tedious and time consuming, esp. for few of my docker builds This is to fasten those things.
- openssl
- libreadline
- zlib
- curl
- uuid
- icu-devtools (linux) or icu4c (MacOS)
This assumes macOS, a Debian-flavored linux. If you need it to work on something else, you may need to modify the plugin. You'll need the dependencies referenced in the list above installed via whatever method you prefer. There are some suggestions below.
Note: This plugin has been tested only on macOS and Debian. Other operating systems have not been tested.
-
Add the plugin:
asdf plugin add https://github.com/HandOfGod94/asdf-postgres-prebuilt.git
-
In your project's
.tool-versionsfile, add the desired Postgres version using this plugin name:postgres-prebuilt 17.4.0 -
Install via asdf:
asdf install
brew install gcc readline zlib curl ossp-uuid icu4c pkg-configIf you are on Apple silicon, you may need to set the HOMEBREW_PREFIX environment
variable to /opt/homebrew. You can do this by putting export HOMEBREW_PREFIX=/opt/homebrew in your ~/.zshrc file. It isn't always
required, but I don't know why this is required for some people. The same goes
for intel machines only the prefix is /usr/local, which can also be dropped
into your ~/.zshrc file export HOMEBREW_PREFIX=/usr/local.
If you are using pkgconfig, you may run into issues with linking, particularly with icu4c. Often they can be resolved by setting your PKG_CONFIG_PATH environment variable to reference where your linked libs live. For example:
brew install gcc readline zlib curl ossp-uuid icu4c pkg-config
export PKG_CONFIG_PATH="/opt/homebrew/bin/pkg-config:$(brew --prefix icu4c)/lib/pkgconfig:$(brew --prefix curl)/lib/pkgconfig:$(brew --prefix zlib)/lib/pkgconfig"sudo apt-get install linux-headers-$(uname -r) build-essential libssl-dev \
libreadline-dev zlib1g-dev libcurl4-openssl-dev uuid-dev icu-devtools libicu-devsudo apt-get install build-essential libssl-dev libreadline-dev zlib1g-dev \
libcurl4-openssl-dev uuid-dev icu-devtools libicu-devsudo dnf install openssl-devel readline-devel zlib-devel libcurl-devel uuid-devel libuuid-develsudo zypper install -t pattern devel_basis
sudo zypper in openssl-devel readline-devel zlib-devel libcurl-devel uuid-devel libuuid-devel-
Add the plugin:
asdf plugin add https://github.com/HandOfGod94/asdf-postgres-prebuilt.git
-
In your project's
.tool-versionsfile, add the desired Postgres version using this plugin name:postgres-prebuilt 17.4.0 -
Install via asdf:
asdf install
To start a new database, you must provide a data directory when starting Postgres:
pg_ctl start -D /path/to/your/data-
Add the plugin:
asdf plugin add https://github.com/HandOfGod94/asdf-postgres-prebuilt.git
-
Create your
.tool-versionsfile in the project that needs Postgres and add:postgres-prebuilt 17.4.0 -
Run
asdf install
- Once it is done, run
pg_ctl start -D /path/to/your/data - Once that starts, run
createdb defaultyou can subdefaultwith whatever you want your db name to be. - Then log in with
psql -d defaultif you didn't use default, make sure you use whatever you put in step 2. - If you need to move your data file around, move data from your install
directory, which will look something like this:
~/.asdf/installs/postgres/9.4.7/datato wherever you want it. Once it is moved, start your db withpg_ctl -D wherever/you/moved/it start. Your postgresql.conf file is in that directory if you need to change the port or anything.
- Just run
pg_ctl stopif you moved your data directory, you have to dopg_ctl -D wherever/you/moved/it stop
Thanks to theseus-rs/postgresql-binaries for providing awesome PostgreSQL binaries.