Skip to content

Rewrite the addon's libchdb path whatever the engine calls it - #80

Merged
ShawnChen-Sirius merged 2 commits into
mainfrom
fix/loader-path-rpath-install-name
Aug 13, 2026
Merged

Rewrite the addon's libchdb path whatever the engine calls it#80
ShawnChen-Sirius merged 2 commits into
mainfrom
fix/loader-path-rpath-install-name

Conversation

@ShawnChen-Sirius

@ShawnChen-Sirius ShawnChen-Sirius commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Closes #79.

The engine release check found this on its first run: chdb-node cannot load its own
addon against chdb-core v26.7.0 on macOS. Both arm64 and x86_64 fail with
ERR_DLOPEN_FAILED; both Linux shards pass.

install_name_tool -change matches the dependency by its exact recorded name, and
that name comes from the engine's install_name, which changed:

v26.5.x    libchdb.so
v26.7.0    @rpath/libchdb.so

The script only knew the first spelling. -change succeeds and does nothing when
the old name does not match, so the addon kept @rpath/libchdb.so — which it has
no LC_RPATH to resolve — and dlopen failed at require() time. The build itself
stayed green, and the otool -L output the script already prints showed the
unrewritten path to anyone who happened to read it.

Both spellings are rewritten now, and the result is verified instead of assumed: a
dependency this script cannot resolve fails the build and names what it found. The
next install_name change should stop the build with a clear message rather than
produce an addon that cannot load.

What was checked

On macOS, by rewriting a built addon's dependency to @rpath/libchdb.so to
reproduce the no-op:

  • the old script leaves it untouched — the CI failure, locally
  • the new script restores @loader_path/../../libchdb.so
  • a second run is idempotent
  • an unknown third spelling (@executable_path/libchdb.so) exits 1 with the
    dependency printed

A full local rebuild against v26.7.0 was not possible — node-gyp 9.3.1 does not run
under Node 26 on this machine — so CI is the first end-to-end build of the addon
against that engine. The v3 suite does pass against v26.7.0's engine with the
existing addon (41 files, 476 tests), so nothing else about that version troubles
the binding; the loader path was the whole of it.

🤖 Generated with Claude Code

Note

Rewrite both known libchdb install name spellings in the macOS addon build script

  • fix_loader_path.sh now loops over both libchdb.so and @rpath/libchdb.so when calling install_name_tool, so the rewrite succeeds regardless of which spelling the build toolchain records.
  • Adds an assertion that the final recorded dependency exactly matches @loader_path/../../libchdb.so, exiting with status 1 and a diagnostic message if not.
  • Adds set -o pipefail and quotes variables throughout for robustness.

Macroscope summarized 2a87342.

The engine release check found this on its first run: chdb-node cannot load its
own addon against chdb-core v26.7.0 on macOS. Both arm64 and x86_64 fail with
ERR_DLOPEN_FAILED while both Linux shards pass.

install_name_tool -change matches the dependency by its exact recorded name, and
that name comes from the engine's install_name, which changed:

    v26.5.x    libchdb.so
    v26.7.0    @rpath/libchdb.so

The script only knew the first spelling. -change succeeds and does nothing when
the old name does not match, so the addon kept @rpath/libchdb.so, which it has no
LC_RPATH to resolve, and dlopen failed at require() time — the build itself was
green, and the otool -L output the script prints showed the unrewritten path to
anyone who looked.

Both spellings are rewritten now, and the result is verified rather than assumed:
a dependency this script cannot resolve fails the build, naming what it found. The
next install_name change should stop the build with a clear message instead of
producing an addon that cannot load.

Checked on macOS by rewriting a built addon's dependency to @rpath/libchdb.so to
reproduce the no-op, confirming the fix restores @loader_path/../../libchdb.so,
that a second run is idempotent, and that an unknown third spelling exits 1. A
full local rebuild against v26.7.0 was not possible — node-gyp 9.3.1 does not run
under Node 26 on this machine — so CI is the first end-to-end build. The v3 suite
does pass against v26.7.0's engine with the existing addon, so nothing else about
that version troubles the binding.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment thread fix_loader_path.sh
Comment thread fix_loader_path.sh Outdated
The verification could pass on an addon that cannot load, in two ways.

`grep -qv "$TARGET"` treats the dots in @loader_path/../../libchdb.so as
wildcards, so @loader_path/ab/cd/libchdb.so matched and was accepted even though
neither rewrite had applied. And the pipeline's status came from that last grep,
so otool failing on a missing or unreadable addon produced no output, no match,
and a clean exit — the case the check exists to catch, passing.

It now reads the dependency out and compares it as a string. One assertion covers
all of it: otool failing, no libchdb dependency at all, more than one, and a path
that merely resembles the target. pipefail goes in as well.

Checked on macOS against four addons: the @rpath spelling is rewritten, a second
run is idempotent, @loader_path/ab/cd/libchdb.so is rejected where the old check
accepted it, and a missing addon is rejected where the old check passed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ShawnChen-Sirius

Copy link
Copy Markdown
Contributor Author

@wudidapaopao please review it

@ShawnChen-Sirius
ShawnChen-Sirius merged commit 2317e7c into main Aug 13, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Engine check: chdb-core v26.7.0 — FAILS

1 participant