fergusstrange / embedded-postgres

Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test
MIT License
819 stars 85 forks source link

Add error info when 'unable to init db' #78

Closed dor-utila closed 2 years ago

dor-utila commented 2 years ago

Currently, I get this error, without any useful information:

panic: localpg: failed to start PgSQL: unable to init database using: /tmp/go_embedded_pgsql_binaries_3773798719/bin/initdb -A password -U username -D /tmp/go_embedded_pgsql_runtime_2105005878/data --pwfile=/tmp/go_embedded_pgsql_runtime_2105005878/pwfile --locale=en_US.UTF-8
jacmacmod commented 1 year ago

I get this error when I try to run psql.Start()

I am using an alpine 12.6 postgres container

        psql := epsql.NewDatabase(epsql.DefaultConfig().
        Username(username).
        Password(password).
        Port(port).
        RuntimePath(fmt.Sprintf("/tmp/encourage_epsql_%d", getInstanceID())).
        Logger(nil),
    )

    c := make(chan os.Signal)
    signal.Notify(c, os.Interrupt)

    go func() {
        select {
        case sig := <-c:
            fmt.Printf("Got %s signal. Aborting...\n", sig)
            psql.Stop()
            os.Exit(1)
        }
    }()

    err = psql.Start()
go run gen/modelgen/*.go
panic: no version found matching 12.6.0
fergusstrange commented 1 year ago

Hey @OnigiriJack what embedded-postgres version/tag are you running? I assume it's https://github.com/fergusstrange/embedded-postgres/releases/tag/v1.5.0 as I think that matched Postgres 12.6.

fergusstrange commented 1 year ago

Just confirmed this version is from before we had Alpine linux support, which was introduced in the very next version 1.6.0.

There's been lots releases since this even, so I'd recommend trying to stay up to date to get the best support. You can see all releases here.

Thanks