Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug: Bun and Deno fail to load JSON extension #4790

Open
nisuxyz opened this issue Jan 24, 2025 · 4 comments
Open

Bug: Bun and Deno fail to load JSON extension #4790

nisuxyz opened this issue Jan 24, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@nisuxyz
Copy link

nisuxyz commented Jan 24, 2025

Kùzu version

v0.7.1

What operating system are you using?

Arch Linux

What happened?

When attempting to load the JSON extension by running the query

INSTALL json;
LOAD EXTENSION json;

It works when using node, but fails when using Bun or Deno:

» deno run -A src/lib/server/db/kuzu.ts                                                                                     
error: Uncaught (in promise) Error: IO exception: Failed to load library: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/json/libjson.kuzu_extension which is needed by extension: json.
Error: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/json/libjson.kuzu_extension: undefined symbol: _ZTVN4kuzu6common18BufferedSerializerE.
» bun run src/lib/server/db/kuzu.ts                                                                                         
error: IO exception: Failed to load library: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/json/libjson.kuzu_extension which is needed by extension: json.
Error: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/json/libjson.kuzu_extension: undefined symbol: _ZTVN4kuzu6common18BufferedSerializerE.

Bun v1.2.0 (Linux x64)
» node ./src/lib/server/db/kuzu.js                                                                                          
{
  db: Database {
    _database: NodeDatabase {},
    _isInitialized: true,
    _initPromise: null,
    _isClosed: false
  },
  conn: Connection {
    _database: Database {
      _database: NodeDatabase {},
      _isInitialized: true,
      _initPromise: null,
      _isClosed: false
    },
    _connection: NodeConnection {},
    _isInitialized: true,
    _initPromise: null,
    _isClosed: false
  }
}

I've checked that the file exists in the correct location. This is the code that's running:

import kuzu from 'kuzu';

const db = new kuzu.Database('./test_db');
const conn = new kuzu.Connection(db);

await conn.query(
	`INSTALL json;
LOAD EXTENSION json;`
);

console.log({ db, conn });

Are there known steps to reproduce?

No response

@nisuxyz nisuxyz added the bug Something isn't working label Jan 24, 2025
@acquamarin
Copy link
Collaborator

Hi @nisuxyz
Thanks for reporting to us, we will fix the issue soon

@acquamarin
Copy link
Collaborator

Hi @nisuxyz
I couldn't reproduce the bug on my machine.
Here is my step to reproduce:
For nodejs, i used:

const kuzu = require("kuzu");

(async () => {
  const db = new kuzu.Database("./test");
  const conn = new kuzu.Connection(db);
  await conn.query(
    "INSTALL json;"
  );
  await conn.query(
    "LOAD EXTENSION JSON;"
  );
})();

And run it as: node test.js

For deno:

import kuzu from "npm:kuzu";

const main = async () => {
  const db = new kuzu.Database("./test");
  const conn = new kuzu.Connection(db);

  await conn.query("INSTALL json;");
  await conn.query("LOAD EXTENSION JSON;");
};

main().catch((err) => {
  console.error("Error:", err);
});

For bun:

import kuzu from "kuzu";

(async () => {
  const db = new kuzu.Database("./test");
  const conn = new kuzu.Connection(db);

  // Create the tables
  await conn.query("INSTALL json;");
  await conn.query("LOAD EXTENSION JSON;");
})();

And run it as: bun run test_bun.test

BTW: Are you compiling the kuzu from source or use the npm package?

@nisuxyz
Copy link
Author

nisuxyz commented Jan 25, 2025

I'm using the npm package, installed via bun. In order to properly install, installed with bun i kuzu and then bun pm trust kuzu. (In deno, installed with deno install --allow-scripts=npm:kuzu@0.7.1) I tested it on a separate ubuntu machine with a freshly installed bun/deno, with the same result for both, and it also was searching for uppercase JSON in the path when searching for the library:

/tmp/kuzu » cat /etc/os-release                                                                                                                                                
PRETTY_NAME="Ubuntu 22.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.5 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/kuzu » ls ~/.kuzu                                                                                                                                                         
ls: cannot access '/home/nisu/.kuzu': No such file or directory
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/kuzu » bun kuzu-load-json.ts                                                                                                                                                    
error: IO exception: Failed to load library: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/JSON/libjson.kuzu_extension which is needed by extension: JSON.
Error: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/JSON/libjson.kuzu_extension: cannot open shared object file: No such file or directory.

Bun v1.2.0 (Linux x64 baseline)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/kuzu » deno -A kuzu-load-json.ts                                                                                                                                            
error: Uncaught (in promise) Error: IO exception: Failed to load library: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/JSON/libjson.kuzu_extension which is needed by extension: JSON.
Error: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/JSON/libjson.kuzu_extension: cannot open shared object file: No such file or directory.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/kuzu » ls ~/.kuzu                                                                                                                                                           
extension
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/kuzu » tree ~/.kuzu                                                                                                                                                             
/home/nisu/.kuzu
└── extension
    └── 0.7.1
        └── linux_amd64
            ├── common
            └── json
                └── libjson.kuzu_extension

5 directories, 1 file
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/kuzu » mv ~/.kuzu/extension/0.7.1/linux_amd64/json ~/.kuzu/extension/0.7.1/linux_amd64/JSON

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/kuzu » bun run kuzu-load-json.ts                                                                                                                                            
error: IO exception: Failed to load library: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/JSON/libjson.kuzu_extension which is needed by extension: JSON.
Error: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/JSON/libjson.kuzu_extension: undefined symbol: _ZTVN4kuzu6common18BufferedSerializerE.

Bun v1.2.0 (Linux x64 baseline)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/kuzu » deno -A kuzu-load-json.ts                                                                                                                                            
error: Uncaught (in promise) Error: IO exception: Failed to load library: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/JSON/libjson.kuzu_extension which is needed by extension: JSON.
Error: /home/nisu/.kuzu/extension/0.7.1/linux_amd64/JSON/libjson.kuzu_extension: undefined symbol: _ZTVN4kuzu6common18BufferedSerializerE.

I tried with top level async as well as the wrapped function like your code:

// kuzu-load-json.ts
import kuzu from 'kuzu';

//const db = new kuzu.Database('./test');
//const conn = new kuzu.Connection(db);

//await conn.query('INSTALL json;');
//await conn.query('LOAD EXTENSION json;');

(async () => {
  const db = new kuzu.Database("./test");
  const conn = new kuzu.Connection(db);

  // Create the tables
  await conn.query("INSTALL json;");
  await conn.query("LOAD EXTENSION JSON;");
})();

@nisuxyz
Copy link
Author

nisuxyz commented Jan 28, 2025

@acquamarin I tested on mac os 13.6.7 with

nisu@Nisus-MacBook-Pro-194:shell master ✗ 2h43m ◒ ⍉ ➜ clang --version
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
nisu@Nisus-MacBook-Pro-194:shell master ✗ 2h43m ◒ ➜

I built and tested the CLI and hit a similar error, symbol not found, for a different symbol:

nisu@Nisus-MacBook-Pro-194:shell master ✗ 2h41m ◒ ⍉ ➜ ./kuzu
Opening the database under in-memory mode.
Enter ":help" for usage hints.
kuzu> INSTALL json;
┌─────────────────────────────────────┐
│ result                              │
│ STRING                              │
├─────────────────────────────────────┤
│ Extension: json has been installed. │
└─────────────────────────────────────┘
(1 tuple)
(1 column)
Time: 5.17ms (compiling), 336.79ms (executing)
kuzu> LOAD EXTENSION json;
Error: IO exception: Failed to load library: /Users/nisu/.kuzu/extension/0.7.0/osx_amd64/json/libjson.kuzu_extension which is needed by extension: json.
Error: dlopen(/Users/nisu/.kuzu/extension/0.7.0/osx_amd64/json/libjson.kuzu_extension, 0x0006): symbol not found in flat namespace '__ZN4kuzu4main13ClientContext16getMemoryManagerEv'.
kuzu>
nisu@Nisus-MacBook-Pro-194:shell master ✗ 2h45m ◒ ➜ ls ~/.kuzu/extension/0.7.0/osx_amd64/json/
libjson.kuzu_extension

I forgot to check out the 0.7.1 tag so I built the latest master branch, I will retry with 0.7.1 tag later tonight to see if the same thing happens

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants