embedded-postgres: Stopped working on IntelliJ 2019.2

Hey, just like for the original otj-pg-embedded project this fork stopped working on my system since upgrading to Mac OS 10.14.6 (latest version). The error I get is java.lang.IllegalStateException: Process [/var/folders/l_/c1b_7t2n39j48k7sbpp54zy00000gn/T/embedded-pg/PG-8eddc1e460ca1c5597350c162933683c/bin/initdb, -A, trust, -U, postgres, -D, /var/folders/l_/c1b_7t2n39j48k7sbpp54zy00000gn/T/epg3835758492450081687, -E, UTF-8] failed.

Deleting the temporary embedded-pg folder does not solve the problem. Do you have any ideas?

About this issue

Commits related to this issue

Most upvoted comments

I had exact problem with otj-pg-embedded and spent too many hours on the issue (downgrading IntelliJ didn’t help). ./gradlew build from mac terminal worked fine but same operation from intellij terminal failed with exactly same message as in the 1st post. Problem was with locales (don’t ask why). Setting these properties in ~/.bash_profile helped: export LC_CTYPE=“en_US.UTF-8” export LC_ALL=“en_US.UTF-8” Hope this saves someone from struggles.

and if you using zsh, put these 2 exports into .zshrc file and restart Intellij

and if you using zsh, put these 2 exports into .zshrc file and restart Intellij

it works, thanks bro, you saved my day.

Just my 2 cents: you can also put the locale environment variables in your gradle build file like this:

test {
    useJUnitPlatform()
    environment "LC_CTYPE", "en_US.UTF-8"
    environment "LC_ALL", "en_US.UTF-8"
}

Full answer here: https://github.com/opentable/otj-pg-embedded/issues/65#issuecomment-567860383

For those running into this on MacOS and using Maven Surefire, you can set the LC_* environment variables like so:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M5</version>
    <configuration>
        <reuseForks>true</reuseForks>
        <environmentVariables>
            <!-- required for running embedded PostgreSQL on MacOS -->
            <!-- see: https://github.com/zonkyio/embedded-postgres/issues/11#issuecomment-533468269 -->
            <LC_CTYPE>en_US.UTF-8</LC_CTYPE>
            <LC_ALL>en_US.UTF-8</LC_ALL>
        </environmentVariables>
    </configuration>
</plugin>

I am having this problem too, on all of

  • MacOS terminal
  • iTerm
  • IntelliJ Terminal
  • IntelliJ runner

with versions

  • 12.0
  • 12.1
  • 12.5

Exporting the environment variables provided by @wiktord did not fix it for IntelliJ (2020.3), or on the MacOS terminals.

Caused by: java.lang.IllegalStateException: Process [/var/folders/pv/c91ppn_s3n36kff_5jqqkh580000gn/T/embedded-pg/PG-abc4d7798f0045b30e0a18facc5799d0/bin/initdb, -A, trust, -U, postgres, -D, /var/folders/pv/c91ppn_s3n36kff_5jqqkh580000gn/T/epg5612952893588405656, -E, UTF-8] failed

Turns out in the end that it was the missing libpq.5.dylib that was the problem for me. I have Postgres.app installed on my machine, so I just symlinked that based on this issue in the postgresql-libpq project https://github.com/lpsmith/postgresql-libpq/issues/9 and it now works. For 12.1. 12.5 still doesn’t work because of

dyld: Library not loaded: @loader_path/../lib/libz.1.dylib Referenced from: /private/var/folders/pv/c91ppn_s3n36kff_5jqqkh580000gn/T/embedded-pg/PG-21706f841db941a04058ca5131a27776/lib/libxml2.2.dylib Reason: no suitable image found. Did find: file system relative paths not allowed in hardened programs no data was returned by command ""/private/var/folders/pv/c91ppn_s3n36kff_5jqqkh580000gn/T/embedded-pg/PG-21706f841db941a04058ca5131a27776/bin/postgres" -V" initdb: error: The program "postgres" is needed by initdb but was not found in the same directory as "/private/var/folders/pv/c91ppn_s3n36kff_5jqqkh580000gn/T/embedded-pg/PG-21706f841db941a04058ca5131a27776/bin/initdb". Check your installation.