bun icon indicating copy to clipboard operation
bun copied to clipboard

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

Open zx8086 opened this issue 1 year ago • 31 comments

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 [email protected] 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 [email protected]

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 [email protected]

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

npm i couchbase [email protected]

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

zx8086 avatar Oct 14 '23 12:10 zx8086

Possibly related to #4959

Electroid avatar Oct 16 '23 16:10 Electroid

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

zx8086 avatar Oct 17 '23 20:10 zx8086

@Electroid Maybe I can reach out to couchbase ?

zx8086 avatar Nov 07 '23 00:11 zx8086

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

Electroid avatar Nov 07 '23 00:11 Electroid

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

mikypilota avatar Nov 16 '23 11:11 mikypilota

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 avatar Nov 21 '23 23:11 zx8086

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

zx8086 avatar Nov 30 '23 02:11 zx8086

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

fatlard1993 avatar Dec 03 '23 21:12 fatlard1993

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).

alumni avatar Dec 15 '23 14:12 alumni

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

zx8086 avatar Dec 22 '23 10:12 zx8086

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.

mikypilota avatar Dec 22 '23 13:12 mikypilota

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 [email protected]):

TypeError: <repo>/node_modules/.pnpm/@[email protected]/node_modules/@sap/hana-client/prebuilt/linuxx86_64-gcc6/hana-client.node: undefined symbol: uv_mutex_lock

alumni avatar Dec 22 '23 15:12 alumni

@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.

zx8086 avatar Jan 11 '24 14:01 zx8086

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

VesterDe avatar Jan 31 '24 09:01 VesterDe

Issue also arrising with node-snap7

calumk avatar Jan 31 '24 11:01 calumk

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

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

zx8086 avatar Feb 18 '24 23:02 zx8086

@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 ?

zx8086 avatar Feb 23 '24 10:02 zx8086

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!');
});

ilchenkoArtem avatar Feb 27 '24 21:02 ilchenkoArtem

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

MZ-Dlovely avatar Feb 28 '24 02:02 MZ-Dlovely

Same in tree-sitter

JacksonKearl avatar Mar 03 '24 06:03 JacksonKearl

Same with ora.

dyld[24639]: missing symbol called
[1]    24639 killed     bun run src/Onboard.ts

tinypell3ts avatar Mar 04 '24 14:03 tinypell3ts

Same with Konva;

benrohel avatar Mar 04 '24 15:03 benrohel

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)

paperclover avatar Mar 04 '24 17:03 paperclover

@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

zx8086 avatar Mar 05 '24 17:03 zx8086

Same on node-ssh

MataAzi avatar Mar 08 '24 17:03 MataAzi

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

gerardmarquinarubio avatar Mar 19 '24 23:03 gerardmarquinarubio

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)

zx8086 avatar Mar 21 '24 20:03 zx8086

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

Electroid avatar Mar 22 '24 02:03 Electroid

frida same

ohroy avatar Apr 09 '24 11:04 ohroy

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

jviel avatar May 21 '24 13:05 jviel