oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.77k stars 2.73k forks source link

libpq package installation error since bun v1.0.20 #7947

Open co-sic opened 9 months ago

co-sic commented 9 months ago

What version of Bun is running?

1.0.21+837cbd60d

What platform is your computer?

Linux 6.5.0-14-generic x86_64 x86_64

What steps can reproduce the bug?

Installing the latest version of the libpq package on bun with version 1.0.20 oder 1.0.21. This worked without an error in 1.0.19.

What is the expected behavior?

No response

What do you see instead?

gyp info it worked if it ends with ok gyp info using node-gyp@10.0.1 gyp info using node@20.9.0 | linux | x64 gyp info find Python using Python version 3.11.6 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args '/home/patrick/development/gastromatic/gastronauten-service/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/home/patrick/development/gastromatic/gastronauten-service/node_modules/libpq/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/home/patrick/development/gastromatic/gastronauten-service/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/patrick/.cache/node-gyp/20.9.0/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/home/patrick/.cache/node-gyp/20.9.0', gyp info spawn args '-Dnode_gyp_dir=/home/patrick/development/gastromatic/gastronauten-service/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/home/patrick/.cache/node-gyp/20.9.0/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/home/patrick/development/gastromatic/gastronauten-service/node_modules/libpq', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] find: ‘/opt/containerd’: Permission denied gyp: Call to 'which pg_config || find /usr/bin /usr/local/bin /usr/pg* /opt -executable -name pg_config -print -quit' returned exit status 1 while in binding.gyp. while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1 gyp ERR! stack at ChildProcess. (/home/patrick/development/gastromatic/gastronauten-service/node_modules/node-gyp/lib/configure.js:271:18) gyp ERR! stack at ChildProcess.emit (node:events:514:28) gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12) gyp ERR! System Linux 6.5.0-14-generic gyp ERR! command "/home/patrick/.nvm/versions/node/v20.9.0/bin/node" "/home/patrick/development/gastromatic/gastronauten-service/node_modules/.bin/node-gyp" "rebuild" gyp ERR! cwd /home/patrick/development/gastromatic/gastronauten-service/node_modules/libpq gyp ERR! node -v v20.9.0 gyp ERR! node-gyp -v v10.0.1 gyp ERR! not ok

Additional information

No response

agjs commented 8 months ago

I'm having the same issue. bun install fails as above when attempting to install pg 8.11.3

co-sic commented 8 months ago

Running it in a dockerfile base on the official image with bun version 1.0.25 i get the following error:

 > [node build 4/9] RUN bun install --frozen-lockfile:
0.698 bun install v1.0.25 (a8ff7be6)
4.905 
4.905 
4.905 gyp info it worked if it ends with ok
4.905 gyp info using node-gyp@10.0.1
4.905 gyp info using node@21.6.0 | linux | x64
4.905 gyp info find Python using Python version 3.11.6 found at "/usr/bin/python3"
4.905 gyp http GET https://nodejs.org/dist/v21.6.0/node-v21.6.0-headers.tar.gz
4.905 gyp http 200 https://nodejs.org/dist/v21.6.0/node-v21.6.0-headers.tar.gz
4.905 gyp http GET https://nodejs.org/dist/v21.6.0/SHASUMS256.txt
4.905 gyp http 200 https://nodejs.org/dist/v21.6.0/SHASUMS256.txt
4.905 gyp info spawn /usr/bin/python3
4.905 gyp info spawn args [
4.905 gyp info spawn args '/usr/src/app/node_modules/node-gyp/gyp/gyp_main.py',
4.905 gyp info spawn args 'binding.gyp',
4.905 gyp info spawn args '-f',
4.905 gyp info spawn args 'make',
4.905 gyp info spawn args '-I',
4.905 gyp info spawn args '/usr/src/app/node_modules/libpq/build/config.gypi',
4.905 gyp info spawn args '-I',
4.905 gyp info spawn args '/usr/src/app/node_modules/node-gyp/addon.gypi',
4.905 gyp info spawn args '-I',
4.905 gyp info spawn args '/root/.cache/node-gyp/21.6.0/include/node/common.gypi',
4.905 gyp info spawn args '-Dlibrary=shared_library',
4.905 gyp info spawn args '-Dvisibility=default',
4.905 gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/21.6.0',
4.905 gyp info spawn args '-Dnode_gyp_dir=/usr/src/app/node_modules/node-gyp',
4.905 gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/21.6.0/<(target_arch)/node.lib',
4.905 gyp info spawn args '-Dmodule_root_dir=/usr/src/app/node_modules/libpq',
4.905 gyp info spawn args '-Dnode_engine=v8',
4.905 gyp info spawn args '--depth=.',
4.905 gyp info spawn args '--no-parallel',
4.905 gyp info spawn args '--generator-output',
4.905 gyp info spawn args 'build',
4.905 gyp info spawn args '-Goutput_dir=.'
4.905 gyp info spawn args ]
4.905 find: /usr/pg*: No such file or directory
4.905 gyp: Call to 'which pg_config || find /usr/bin /usr/local/bin /usr/pg* /opt -executable -name pg_config -print -quit' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
4.905 gyp ERR! configure error 
4.905 gyp ERR! stack Error: `gyp` failed with exit code: 1
4.905 gyp ERR! stack at <anonymous> (/usr/src/app/node_modules/node-gyp/lib/configure.js:270:66)
4.905 gyp ERR! stack at emit (node:events:154:48)
4.905 gyp ERR! stack at #handleOnExit (node:child_process:537:16)
4.905 gyp ERR! stack at processTicksAndRejections (:12:39)
4.905 gyp ERR! System Linux 6.5.0-15-generic
4.905 gyp ERR! command "/usr/local/bin/bun" "/usr/src/app/node_modules/.bin/node-gyp" "rebuild"
4.905 gyp ERR! cwd /usr/src/app/node_modules/libpq
4.905 gyp ERR! node -v v21.6.0
4.905 gyp ERR! node-gyp -v v10.0.1
4.905 gyp ERR! not ok 
4.905 
4.905 error: install script from "libpq" exited with 1
------
failed to solve: process "/bin/sh -c bun install --frozen-lockfile" did not complete successfully: exit code: 1

Also i had to manually add python3, which was not required before (Bun Version 1.0.19)

Jarred-Sumner commented 8 months ago

@co-sic are you adding pg-native as a dependency?

co-sic commented 8 months ago

@Jarred-Sumner i did not, but i just tried it out and the error is still the same.

co-sic commented 8 months ago

@Jarred-Sumner its really wierd. In my project i don't use libpg directly but through @mikro-orm/postgresql. I just checked, if i only install this, it works even with bun v 1.0.25. But if i also add the dependency semantic-release, it fails. Not sure what the connection is there.

I added a minimal reproduction repo here: https://github.com/co-sic/bun-playground , you can just build the docker file to see the error. If you change the bun version in the docker file to 1.0.16, it will work (you could also remove the installation of python in that version and it still works).

EDIT: i actually removed the mikro-orm package and directly used libpq as a dependency in the example. Still the same behaviour

co-sic commented 6 months ago

I tried it again with bun v1.1.0 and also narrowed it down to just install the libpq library. The first installation always fails with the error below. Current workaround is, to ignore the error and just install again, then it will work.

bun install v1.1.0 (5903a614)
  ⚙️  libpq [1/1] 

gyp info it worked if it ends with ok
gyp info using node-gyp@10.1.0
gyp info using node@20.9.0 | linux | x64
gyp info find Python using Python version 3.11.6 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/tmp/bunx-1000-node-gyp@latest/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/patrick/development/gastromatic/gastronauten-service/node_modules/libpq/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/tmp/bunx-1000-node-gyp@latest/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/patrick/.cache/node-gyp/20.9.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/patrick/.cache/node-gyp/20.9.0',
gyp info spawn args '-Dnode_gyp_dir=/tmp/bunx-1000-node-gyp@latest/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/patrick/.cache/node-gyp/20.9.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/patrick/development/gastromatic/gastronauten-service/node_modules/libpq',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
find: ‘/opt/containerd’: Permission denied
gyp: Call to 'which pg_config || find /usr/bin /usr/local/bin /usr/pg* /opt -executable -name pg_config -print -quit' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.<anonymous> (/tmp/bunx-1000-node-gyp@latest/node_modules/node-gyp/lib/configure.js:297:18)
gyp ERR! stack at ChildProcess.emit (node:events:514:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Linux 6.5.0-26-generic
gyp ERR! command "/home/patrick/.nvm/versions/node/v20.9.0/bin/node" "/tmp/bunx-1000-node-gyp@latest/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /home/patrick/development/gastromatic/gastronauten-service/node_modules/libpq
gyp ERR! node -v v20.9.0
gyp ERR! node-gyp -v v10.1.0
gyp ERR! not ok 

error: install script from "libpq" exited with 1
GWSzeto commented 5 months ago

Running into the same issue and resolving the same way as @co-sic . Only issue is when deploying to vercel, this fail on the build step

EDIT: was able to get around the issue on vercel by overriding the install command with bun i || true && bun i