Bug Report: koffi Library Fails to Load Shared Library in Node.js v20.11.1 Environment #16619

Closed
opened 2026-02-21 19:26:56 -05:00 by yindo · 1 comment
Owner

Originally created by @zhangshican on GitHub (Sep 1, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.7.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

In the Dify sandbox environment, run a Node.js script that uses the koffi library to load a shared library (.so file).

The error occurs even when the shared library file is in the same directory as the script and the code uses the correct relative path.

The error shows that koffi cannot find the shared library file within the sandbox environment.

Error Log
:28:49 Node.js v20.11.1 9-49b5-b386-e31edef6ffac/var/sandbox/sandbox-nodejs/nodejs-project/node_temp/node_temp/node_modules/koffi/index.js:480 let lib = native3.load(...args); ^ Error: Failed to load shared library: cannot open shared object file: No such file or directory at obj.load (/tmp/sandbox-a2c93421-d5f9-49b5-b386-e31edef6ffac/var/sandbox/sandbox-nodejs/nodejs-project/node_temp/node_temp/node_modules/koffi/index.js:480:27) at Object.<anonymous> (/tmp/sandbox-a2c93421-d5f9-49b5-b386-e31edef6ffac/var/sandbox/sandbox-nodejs/nodejs-project/node_temp/node_temp/test.js:4:19) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49 Node.js v20.11.1 error: exit status 1

✔️ Expected Behavior

The koffi library should successfully load the shared library, allowing the script to execute as expected.

Actual Behavior

koffi fails to load the shared library, causing the program to exit with a "No such file or directory" error.

Originally created by @zhangshican on GitHub (Sep 1, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.7.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce In the Dify sandbox environment, run a Node.js script that uses the koffi library to load a shared library (.so file). The error occurs even when the shared library file is in the same directory as the script and the code uses the correct relative path. The error shows that koffi cannot find the shared library file within the sandbox environment. Error Log `:28:49 Node.js v20.11.1 9-49b5-b386-e31edef6ffac/var/sandbox/sandbox-nodejs/nodejs-project/node_temp/node_temp/node_modules/koffi/index.js:480 let lib = native3.load(...args); ^ Error: Failed to load shared library: cannot open shared object file: No such file or directory at obj.load (/tmp/sandbox-a2c93421-d5f9-49b5-b386-e31edef6ffac/var/sandbox/sandbox-nodejs/nodejs-project/node_temp/node_temp/node_modules/koffi/index.js:480:27) at Object.<anonymous> (/tmp/sandbox-a2c93421-d5f9-49b5-b386-e31edef6ffac/var/sandbox/sandbox-nodejs/nodejs-project/node_temp/node_temp/test.js:4:19) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49 Node.js v20.11.1 error: exit status 1` ### ✔️ Expected Behavior The koffi library should successfully load the shared library, allowing the script to execute as expected. ### ❌ Actual Behavior koffi fails to load the shared library, causing the program to exit with a "No such file or directory" error.
yindo added the 🐞 bug label 2026-02-21 19:26:56 -05:00
yindo closed this issue 2026-02-21 19:26:56 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 1, 2025):

Hi @zhangshican! I'm Dosu and I’m helping the dify team.

This is a confirmed limitation in the Dify sandbox: Node.js scripts cannot load third-party libraries or shared libraries like koffi, and there are no configuration options or workarounds to specify shared library paths for Node.js in the sandbox environment. Only Python currently supports installing extra plugins and dependencies in the sandbox; JavaScript (Node.js) does not, and this is a known issue the team is working on fixing. If you need shared library support, consider running your Node.js code outside the sandbox or using Python if possible. You can track future updates or feature support in the Dify repository and documentation.
Reference 1 | Reference 2 | Reference 3

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 1, 2025): <!-- Greeting --> Hi @zhangshican! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> This is a confirmed limitation in the Dify sandbox: Node.js scripts cannot load third-party libraries or shared libraries like koffi, and there are no configuration options or workarounds to specify shared library paths for Node.js in the sandbox environment. Only Python currently supports installing extra plugins and dependencies in the sandbox; JavaScript (Node.js) does not, and this is a known issue the team is working on fixing. If you need shared library support, consider running your Node.js code outside the sandbox or using Python if possible. You can track future updates or feature support in the Dify repository and documentation. [Reference 1](https://github.com/langgenius/dify/issues/16253) | [Reference 2](https://github.com/langgenius/dify/issues/15979) | [Reference 3](https://github.com/langgenius/dify-docs/issues/124) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/13595328-97bc-4522-b538-a2b204760aa2?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/13595328-97bc-4522-b538-a2b204760aa2?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/13595328-97bc-4522-b538-a2b204760aa2?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/13595328-97bc-4522-b538-a2b204760aa2?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/13595328-97bc-4522-b538-a2b204760aa2?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/13595328-97bc-4522-b538-a2b204760aa2?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/13595328-97bc-4522-b538-a2b204760aa2?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/24919)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#16619