Skip to content

SettingsBuilder not using the correct installation_dir #235

@dacut

Description

@dacut

What steps will reproduce the bug? (please provide code snippet if relevant)
I have a barebones test case (running MacOS 26.3.1 on an M1 Macbook Pro, if that's relevant):

use postgresql_embedded::{PostgreSQL, SettingsBuilder, VersionReq};

#[tokio::main]
async fn main() {
    let version_req = VersionReq::parse("=18.3").unwrap();
    let settings = SettingsBuilder::new()
        .version(version_req)
        .trust_installation_dir(true)
        .build();
    println!("binary_dir: {:?}", settings.binary_dir());
    println!("installation_dir: {:?}", settings.installation_dir);
    println!("data_dir: {:?}", settings.data_dir);
    println!("releases_url: {:?}", settings.releases_url);
    println!("socket_dir: {:?}", settings.socket_dir);
    let mut db = PostgreSQL::new(settings);
    db.setup().await.unwrap();
    db.start().await.unwrap();
    db.stop().await.unwrap();
}

What happens?

This prints the following output:

binary_dir: "/Users/dacut/.theseus/postgresql/bin"
installation_dir: "/Users/dacut/.theseus/postgresql"
data_dir: "/var/folders/vg/95k36mn14x3_1cxqb8sd9ktw0000gn/T/.tmpRlHeVQ"
releases_url: "https://github.com/theseus-rs/postgresql-binaries"
socket_dir: None

And then crashes:

thread 'main' (20397436) panicked at src/main.rs:16:22:
called `Result::unwrap()` on an `Err` value: DatabaseInitializationError("No such file or directory (os error 2)")

I'll include the full stack trace in a comment in case it's relevant.

What did you expect to happen instead?

This should initialize the database properly

Other observations

The installation_dir appears to be incorrect. On my system, the resulting database is installed to $HOME/.theseus/postgresql/18.3.0.

If I manually force the install_dir in SettingsBuilder to be $HOME/.theseus/postgresql/18.3.0, this works as expected.

Information about your environment

  • postgresql_embedded version: 0.20.2
  • Database version: 18.3.0
  • Operating system: MacOS 26.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions