leinelissen / embedded-postgres

🐘 A Node package that allows you to spawn a Postgresql cluster programatically.
MIT License
53 stars 10 forks source link

Is Bunjs supported? #13

Open ansarizafar opened 1 week ago

ansarizafar commented 1 week ago

I am trying to use the latest version of this amazing lib on Ubuntu 22.04 with Bunjs but I am getting this error

/home/zafaransari/projects/bun/postgres/node_modules/@embedded-postgres/linux-x64/native/bin/initdb: error while loading shared libraries: libicuuc.so.60: cannot open shared object file: No such file or directory

If I use Nodejs then I get this error

/home/zafaransari/projects/bun/postgres/node_modules/@embedded-postgres/linux-x64/native/bin/initdb: error while loading shared libraries: libicuuc.so.60: cannot open shared object file: No such file or directory
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Postgres init script exited with code 127. Please check the logs for extra info. The data directory might already exist.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v21.5.0

Is there any solution?

leinelissen commented 1 week ago

Bun is not explicitly supported but there shouldn't be any issues with running it. I've just tested Bun with the latest version of the package on an Ubuntu 22.04 VM and everything appears to be working smoothly.

The error you're encountering is because the Postgres binary cannot find a library that should be bundled with embedded-postgres. I suspect that there's an issue with creating the symlinks that Postgres requires when installing the package. Because we cannot create symlinks from tar files, this is a manual step after package installation that is performed by using a postinstall script.

Can you reinstall the package and check the console for any errors that pop-up?