embedded-postgres-binaries: macOS Catalina and Mojave fails due to hardened rules
Since the last release, 9.6.17, i’m no longer able to use embedded-postgres. I get an IllegalStateException saying initDb failed:
27.03.2020 11:37:39.309 [main] WARN o.s.w.c.s.GenericWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [liquibase.integration.spring.SpringLiquibase]:
Factory method 'liquibase' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource':
FactoryBean threw exception on object creation; nested exception is com.google.common.util.concurrent.UncheckedExecutionException:
java.lang.IllegalStateException:
Process [/var/folders/3n/7mpl5l6j62v11xttxsjsk4wcfmyktc/T/embedded-pg/PG-5001232d5f8eb9a35a50839624b9a760/bin/initdb, -A, trust, -U, postgres, -D, /var/folders/3n/7mpl5l6j62v11xttxsjsk4wcfmyktc/T/epg17954755376373960693, -E, UTF-8] failed
Some more investigation reveals that initDb is indeed unable to run:
❯ /var/folders/3n/7mpl5l6j62v11xttxsjsk4wcfmyktc/T/embedded-pg/PG-5001232d5f8eb9a35a50839624b9a760/bin/initdb -A trust -U postgres -D /var/folders/3n/7mpl5l6j62v11xttxsjsk4wcfmyktc/T/epg17954755376373960693 -E UTF-8
dyld: Library not loaded: @loader_path/../lib/libz.1.dylib
Referenced from: /private/var/folders/3n/7mpl5l6j62v11xttxsjsk4wcfmyktc/T/embedded-pg/PG-5001232d5f8eb9a35a50839624b9a760/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/3n/7mpl5l6j62v11xttxsjsk4wcfmyktc/T/embedded-pg/PG-5001232d5f8eb9a35a50839624b9a760/bin/postgres" -V"
The program "postgres" is needed by initdb but was not found in the
same directory as "/private/var/folders/3n/7mpl5l6j62v11xttxsjsk4wcfmyktc/T/embedded-pg/PG-5001232d5f8eb9a35a50839624b9a760/bin/initdb".
Check your installation.
It seems like this issue: #17 seems to cause this problem since going back to 9.6.16 fixes the issue.
I’m running on MacOS 10.15.2 and java 11:
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25
Commits related to this issue
- Using embedded PostgreSQL binaries 12.1 for now. There is an issue with versions after this one which hasn't been solved yet (https://github.com/zonkyio/embedded-postgres-binaries/issues/21). — committed to guisil/stolat by guisil 4 years ago
- #21 fix missing libz library — committed to zonkyio/embedded-postgres-binaries by tomix26 4 years ago
- #21 fix missing libz library — committed to zonkyio/embedded-postgres-binaries by tomix26 4 years ago
- #21 fix missing libz library — committed to zonkyio/embedded-postgres-binaries by tomix26 4 years ago
- Merge pull request #32 from zonkyio/missing-libz-library #21 Fix missing libz library — committed to zonkyio/embedded-postgres-binaries by tomix26 4 years ago
All versions of zonky embedded postgres still fail for me. MacOS 12.2 M1 Pro
FYI Using these dependencies is working for me:
I was using only embedded-database-spring-test 1.6.3 before:
After upgrading I just needed to set the provider and type for the embedded db:
The fixed versions were not officially released yet, I’ve released them right now. But since already published versions cannot be overridden in maven central repository, I had to release special versions with
-1suffix. So fixed versions are9.5.24-1,9.6.20-1,10.15.0-1,11.10.0-1,12.5.0-1,13.1.0-1. See the releases page for more information.Same problem here with MacOS Monetary (12.3.1) M1!
BTW for people thinking they are affected by exactly this bug: Make sure you checked your locale settings as well! This does not seem important but it is (postgres is quite picky about some environment settings). See for more details: https://stackoverflow.com/questions/7165108/in-os-x-lion-lang-is-not-set-to-utf-8-how-to-fix-it/8161863#8161863
Downgrading to 12.1 fixed this for me thankfully 😥
Ok, I already know what is causing the problem.
The problem is in EnterpriseDB binaries. Because the MacOS bundle contains exactly these binaries but only in reduced and repacked form. The previous binaries were not notarized and was running in legacy mode, so it was working fine. Whereas the new version of binaries are running in the hardened runtime which was introduced in macOS 10.14 Mojave. Apps running in the hardened runtime have some restrictons. One of them relates to using dynamically linked libraries. For using them must be enabled runtime exception to allow DYLD environment variables and maybe some other exceptions.
Unfortunately, at this moment the EnterpriseDB binaries do not have this exception enabled, so it does not work with the latest MacOS versions (Mojave and Catalina). We can only hope that people from EnterpriseDB will fix this issue and the next versions will be working again.
@chrisjenx Thanks for the confirmation.