oven-sh / bun

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

dyld[30845]: missing symbol called / undefined symbol: uv_mutex_lock #6506

Open zx8086 opened 10 months ago

zx8086 commented 10 months ago

What version of Bun is running?

1.0.6

What platform is your computer?

Darwin 22.5.0 arm64 arm

What steps can reproduce the bug?

Install Couchbase Server / Couchbase Capella Cloud -> docker run -t --name db -p 8091-8096:8091-8096 -p 11210-11211:11210-11211 couchbase/server:enterprise-7.2.0 or https://cloud.couchbase.com/ Install Couchbase SDK -> bun add couchbase@4.2.7 Run Bun -> bun index.js

index.js

const couchbase = require('couchbase')

async function main() {
  const cluster = await couchbase.connect(
    'couchbase://127.0.0.1',
    {
      username: 'username',
      password: 'password',
    })

  const bucket = cluster.bucket('default')
  const coll = bucket.defaultCollection()
  await coll.upsert('testdoc', { foo: 'bar' })

  const res = await coll.get('testdoc')
  console.log(res.content)
}

// Run the main function
main()
  .then((_) => {
    console.log ('Success!')
  })
  .catch((err) => {
    console.log('ERR:', err)
  })

Reference: https://docs.couchbase.com/nodejs-sdk/current/hello-world/start-using-sdk.html

What is the expected behavior?

Runs and connects to a Couchbase Instance

What do you see instead?

bun add couchbase@4.2.5

bun run index.js       
121 |         throw e;
122 |       }
123 |     }
124 |   }
125 | 
126 |   err = new Error(
            ^
error: Could not locate the bindings file. Tried:
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/build/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/build/Debug/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/build/Release/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/out/Debug/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/Debug/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/out/Release/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/Release/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/build/default/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/compiled/20.8.0/darwin/arm64/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/addon-build/release/install-root/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/addon-build/debug/install-root/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/addon-build/default/install-root/couchbase_impl.node
 → /Users/me/Documents/bun-couchbase/node_modules/couchbase/lib/binding/node-v115-darwin-arm64/couchbase_impl.node
      at bindings (/Users/me/Documents/bun-couchbase/node_modules/bindings/bindings.js:126:8)
      at /Users/me/Documents/bun-couchbase/node_modules/couchbase/dist/binding.js:160:6
      at globalThis (/Users/me/Documents/bun-couchbase/node_modules/couchbase/dist/binding.js:161:18)
      at overridableRequire (:1:20)
      at /Users/me/Documents/bun-couchbase/node_modules/couchbase/dist/couchbase.js:21:18
      at globalThis (/Users/me/Documents/bun-couchbase/node_modules/couchbase/dist/couchbase.js:81:44)
      at overridableRequire (:1:20)
      at /Users/me/Documents/bun-couchbase/index.js:1:6
      at globalThis (/Users/me/Documents/bun-couchbase/index.js:29:28)

bun add couchbase@4.2.7

dyld[30845]: missing symbol called
zsh: killed     bun run index.js

npm i couchbase couchbase@4.2.7

233 |     target.push(`libc=${libc}`)
234 |   }
235 |   if (typeof __webpack_require__ === 'function') {
236 |     target.push('webpack=true')
237 |   }
238 |   throw new Error(
            ^
error: Could not find native build for platform=darwin, arch=arm64, runtime=node, nodeVersion=20.8.0, sslType=openssl3 loaded from /Users/me/Documents/bun-couchbase/node_modules/couchbase.
      at resolvePrebuild (/Users/me/Documents/bun-couchbase/node_modules/couchbase/scripts/prebuilds.js:238:8)
      at loadPrebuild (/Users/me/Documents/bun-couchbase/node_modules/couchbase/scripts/prebuilds.js:119:24)
      at /Users/me/Documents/bun-couchbase/node_modules/couchbase/dist/binding.js:158:6
      at globalThis (/Users/me/Documents/bun-couchbase/node_modules/couchbase/dist/binding.js:159:18)
      at overridableRequire (:1:20)
      at /Users/me/Documents/bun-couchbase/node_modules/couchbase/dist/couchbase.js:21:18
      at globalThis (/Users/me/Documents/bun-couchbase/node_modules/couchbase/dist/couchbase.js:102:44)
      at overridableRequire (:1:20)

Additional information

No response

Electroid commented 10 months ago

Possibly related to #4959

zx8086 commented 10 months ago

@Electroid How would i be able to verify? The trustedDependancies approach doesn't work.

zx8086 commented 10 months ago

@Electroid Maybe I can reach out to couchbase ?

Electroid commented 10 months ago

This is very likely a bug in Bun, not couchbase. We will fix it.

mikypilota commented 9 months ago

Same happening with libxmljs. The library needs to run compilation scripts so it's added to trustedDependencies, however, after installation, when running any file with bun /path/to/file.ts that imports and uses libxmljs, I get:

dyld[<process number>]: missing symbol called
[1]    <process number> killed     bun ./bin/file.ts

Runs fine on ts-node

zx8086 commented 9 months ago

Same happening with libxmljs. The library needs to run compilation scripts so it's added to trustedDependencies, however, after installation, when running any file with bun /path/to/file.ts that imports and uses libxmljs, I get:


dyld[<process number>]: missing symbol called

[1]    <process number> killed     bun ./bin/file.ts

Runs fine on ts-node

Yeah along the same lines

zx8086 commented 9 months ago

Any progress / ETA on this ? Been wanting to use Bun for some projects but at this point if this is abandoned, would like to know

fatlard1993 commented 9 months ago

Seeing the same thing when trying to use robotjs after getting it to build by installing node-gyp and adding robotjs to the trustedDependencies

alumni commented 8 months ago

Same thing happens in bun 1.0.18 on macos arm64 if I do require('@sap/hana-client'). The package was installed with pnpm and comes with prebuilt binaries (no postinstall step).

zx8086 commented 8 months ago

SAP and Couchbase are two enterprise solution together with OpenTelemetry that we use in our corporation. This to me makes Bun not production ready.

mikypilota commented 8 months ago

If my understanding is correct, it is not the specific compatibility with CouchBase, SAP or libxmljs that has to be looked into, but rather that these packages rely on some modules for which Bun does not yet offer compatibility.

They must be yellow or red modules of this list.

We need to find a quick way to determine which of these modules is the culprit. Maybe we will find out the underlying issue is all about the same module for all of the above mentioned packages, so we can ask to prioritise its implementation for next releases. I would love to help myself for the implementation of these but my Zig skills are not yet up to speed for it.

alumni commented 8 months ago

SAP and Couchbase are two enterprise solution together with OpenTelemetry that we use in our corporation.

For telemetry we're using dynatrace like most SAP products, it used to crash at import when bun 1.0.0 was launched, now it's no longer crashing (at least at import, haven't tried anything more than that). But yeah, as an alternative, support for any other OpenTelemetry-compatible framework would be great to have.

For @sap/hana-client, there is a pure-JS client called hdb, but it's quite buggy with certain data types even on nodejs, so the NAPI client would be great to have.

BTW, on Linux x64 the error is more explicit (using bun@1.0.19):

TypeError: <repo>/node_modules/.pnpm/@sap+hana-client@2.19.20/node_modules/@sap/hana-client/prebuilt/linuxx86_64-gcc6/hana-client.node: undefined symbol: uv_mutex_lock
zx8086 commented 7 months ago

@Electroid @Jarred-Sumner

Any timelines for when this will be looked into or completed, it seems every other NPM compatibility issue is being looked into and resolved, even when logged after this.

VesterDe commented 7 months ago

This same issue seems to happen when importing any version of pdfjs-dist. Which is the prebuilt version of this.

calumk commented 7 months ago

Issue also arrising with node-snap7

zx8086 commented 6 months ago

Waiting for this to ditch node... this and http2 for gRPC

305356514-e07c2d6f-709d-42c6-bb86-70b33ba329fb

zx8086 commented 6 months ago

@Electroid @Jarred-Sumner

We were excited for Bun, eagerly anticipating starting new projects with Bun, which means delaying or holding development to really give us time to implement & test before fully committing.

Would help to know if this is feasible & timelines or just to abandon this endeavour. Do you need any help ?

ilchenkoArtem commented 6 months ago

the same with subset-iconfont package

import { MiProvider } from 'subset-iconfont';

const mdi = new MiProvider(['shopping-cart', "shopping-cart-checkout", "delete"], {
  formats: ['woff2'],
  generateMinCss: false,
  generateCssMap: false,
  writeOutFiles: ['web', 'webfonts',"metadata"]
});

mdi.makeFonts('./outputDir').then((result) => {
  console.log('Done!');
});
MZ-Dlovely commented 6 months ago

new discovery: This error can also occur in ssh2

import 'ssh2'

console.log('ssh2')
// const ssh2 = new Client()
// ssh2.on('ready', () => {
//   console.log('Client :: ready')
//   ssh2.end()
// })
$ bun run test.ts
dyld[7636]: missing symbol called
JacksonKearl commented 6 months ago

Same in tree-sitter

tinypell3ts commented 6 months ago

Same with ora.

dyld[24639]: missing symbol called
[1]    24639 killed     bun run src/Onboard.ts
benrohel commented 6 months ago

Same with Konva;

paperdave commented 6 months ago

missing symbol called can mean any missing symbol, but the uv_mutex_t apis (mentioned at one point in this thread) should not be hard to implement (bun does not use libuv on posix platforms)

zx8086 commented 6 months ago

@Electroid @Jarred-Sumner @paperdave Thanks for the insight, got it working and now testing... hopefully should be able to close this.

Running brew install --HEAD libuv Removing bun.lock & node_modules Bun Update (with couchbase still in trusted dependencies)

Got a Post install message

MataAzi commented 5 months ago

Same on node-ssh

gerardmarquinarubio commented 5 months ago

This same issue seems to happen when importing any version of pdfjs-dist. Which is the prebuilt version of this.

Check https://github.com/oven-sh/bun/issues/6608#issuecomment-2008316410, solved it by doing some manual module overriding shenanigans

zx8086 commented 5 months ago

Figure out the needed dependancies required for postinstall

Running brew install --HEAD libuv Removing bun.lock & node_modules Bun Update (with couchbase still in trusted dependencies)

Electroid commented 5 months ago

While that is a workaround, we do want to have a proper fix.

ohroy commented 4 months ago

frida same

jviel commented 3 months ago

the proposed workaround didn't work for me with Bun v1.1.8 on Linux or Mac. trying to use zeromq library

bun: symbol lookup error: /node_modules/zeromq/prebuilds/linux-x64/node.napi.glibc.node: undefined symbol: uv_async_init

I can't wait until this is fixed 🤞 - It's the last blocker for my ditching Node + Express + Socket.io

alumni commented 3 months ago

the proposed workaround didn't work for me with Bun v1.1.8 on Linux or Mac.

@jviel Didn't work for me either.

Kulimeya commented 2 months ago

Have the same problem with ssh2. I installed it, pushed it to my test server without local testing, worked. Then some hours later I wanted to run my local test setup on my Mac, got this error. Is the only solution to remove it from my project even if my code is already working on the server, just so I can continue developing locally?

rgigger commented 2 months ago

Same here. Trying to use ssh2 but I get the above error.

Max2Wynn commented 1 week ago

1.1.25 workds. just run bun upgrade