Skip to content

[bug] ast-grep-napi.linux-arm64-gnu.node: undefined symbol: le16toh inside Debian devcontainer on macOSΒ #2429

@cdubz

Description

@cdubz

Please read the FAQ for the bug you encountered.

  • I have read the existing FAQ

⏯ Playground Link

https://github.com/cdubz/ast-grep-undefined-symbol-le16toh

πŸ’» Code

The issue here is very environment specific. I have tried to narrow it down as much as possible, but the easiest reproduction is specifically in Docker container on macOS using VSCode.

  1. Open VSCode
  2. Run Command > Dev Containers: Clone Repository in Container Volume.
  3. Select repo https://github.com/cdubz/ast-grep-undefined-symbol-le16toh and branch main
  4. npm install
  5. node -e 'console.log(require("@ast-grep/napi").Lang.JavaScript)'

Note: the devcontainer is using Microsoft's base 24-trixie variant for javascript-node development: https://github.com/devcontainers/images/blob/main/src/javascript-node/history/4.0.3.md#variant-24-trixie

πŸ™ Actual behavior

An error is thrown: /workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi-linux-arm64-gnu/ast-grep-napi.linux-arm64-gnu.node: undefined symbol: le16toh

/workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi/index.js:385
    throw new Error(
    ^

Error: Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
    at Object.<anonymous> (/workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi/index.js:385:11)
    at Module._compile (node:internal/modules/cjs/loader:1761:14)
    at Object..js (node:internal/modules/cjs/loader:1893:10)
    at Module.load (node:internal/modules/cjs/loader:1481:32)
    at Module._load (node:internal/modules/cjs/loader:1300:12)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
    at Module.require (node:internal/modules/cjs/loader:1504:12)
    at require (node:internal/modules/helpers:152:16)
    at [eval]:1:13 {
  [cause]: [
    Error: Cannot find module './ast-grep-napi.linux-arm64-gnu.node'
    Require stack:
    - /workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi/index.js
        at Module._resolveFilename (node:internal/modules/cjs/loader:1421:15)
        at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
        at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
        at Module._load (node:internal/modules/cjs/loader:1227:37)
        at TracingChannel.traceSync (node:diagnostics_channel:328:14)
        at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
        at Module.require (node:internal/modules/cjs/loader:1504:12)
        at require (node:internal/modules/helpers:152:16)
        at requireNative (/workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi/index.js:237:18)
        at Object.<anonymous> (/workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi/index.js:362:17) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [
        '/workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi/index.js'
      ]
    },
    Error: /workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi-linux-arm64-gnu/ast-grep-napi.linux-arm64-gnu.node: undefined symbol: le16toh
        at Object..node (node:internal/modules/cjs/loader:1920:18)
        at Module.load (node:internal/modules/cjs/loader:1481:32)
        at Module._load (node:internal/modules/cjs/loader:1300:12)
        at TracingChannel.traceSync (node:diagnostics_channel:328:14)
        at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
        at Module.require (node:internal/modules/cjs/loader:1504:12)
        at require (node:internal/modules/helpers:152:16)
        at requireNative (/workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi/index.js:242:18)
        at Object.<anonymous> (/workspaces/ast-grep-undefined-symbol-le16toh/node_modules/@ast-grep/napi/index.js:362:17)
        at Module._compile (node:internal/modules/cjs/loader:1761:14) {
      code: 'ERR_DLOPEN_FAILED'
    }
  ]
}

Node.js v24.12.0

πŸ™‚ Expected behavior

The output of this test command should be simply: JavaScript

The error is not thrown in versions of @ast-grep/napi before 0.40.0.

To confirm from the test environment described above:

  1. npm install @ast-grep/napi@0.39.9
  2. node -e 'console.log(require("@ast-grep/napi").Lang.JavaScript)'

Additional information about the issue

I realize there are a lot of dependencies to reproduce here. @ast-grep/napi comes to me as dependency on a large project so I worked to isolate this as much as I could. If there is anything else I can do to try to further isolate this for testing and support, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstreamUpstream issue from tree-sitter

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions