Skip to content

fix(ci): give the musl build a Node the napi CLI can run - #626

Merged
kartikeya-27 merged 1 commit into
masterfrom
fix/node-musl-image-node20
Aug 3, 2026
Merged

fix(ci): give the musl build a Node the napi CLI can run#626
kartikeya-27 merged 1 commit into
masterfrom
fix/node-musl-image-node20

Conversation

@pratyush618

@pratyush618 pratyush618 commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Build aarch64-unknown-linux-musl failed on the node-v0.22.0 publish run:

> napi build --platform --release ...
import { styleText } from 'node:util';
         ^^^^^^^^^
SyntaxError: The requested module 'node:util' does not provide an export named 'styleText'
Node.js v18.20.5

ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine bundles Node 18.20.5 on an Alpine 3.20 base.
@napi-rs/cli v3 pulls @inquirer/core v11, which imports styleText from node:util
added in Node 20. The workflow already prints the warning right above the crash:
Unsupported engine: wanted {"node":">=20"} (current v18.20.5). This surfaced with the napi
2 → 3 upgrade (#581) and only on musl, since that is the one target built inside the image.

The image's /etc/apk/repositories points at edge, so apk add nodejs there installs Node
24 built against a newer libc/openssl and it fails to relocate:

Error relocating /usr/bin/node: sqlite3session_create: symbol not found
Error relocating /usr/bin/node: EVP_MD_CTX_get_size_ex: symbol not found

Repointing apk at the image's own Alpine release gives Node 20.15.1, ABI-consistent with the
base. The branch is read from /etc/alpine-release rather than hardcoded, so a rebased image
stays consistent instead of silently pulling mismatched packages.

Extracted the container steps to a script

The step had grown into a quoted shell blob inside YAML. It now lives in
.github/scripts/build-node-native-musl.sh, which is shellcheck-clean and runnable locally
against the same image — the only way this path gets exercised, since no PR job builds musl.

Two other things fell out of the move:

  • The pnpm pin is read from packageManager instead of being a second copy of 10.33.0 that
    could drift from sdks/node/package.json.
  • The apt-get branch is gone. Only the two musl entries set docker:, and both are Alpine.

Verification

Ran the committed script in ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine against a clean
git archive of the tree, skipping only the long Rust build:

node -v            → v20.15.1
pnpm -v            → 10.33.0
pnpm install --frozen-lockfile → OK
pnpm exec napi --version       → 3.8.0

That last command is the one that raised the SyntaxError. Confirmed the causality both ways in
the image: under the bundled Node 18 the same napi --version reproduces the crash exactly;
under 20.15.1 it prints the version.

shellcheck clean, sh -n clean, workflow YAML parses.

Follow-up

node-v0.22.0 already points at 913d5331, which predates this. Once merged, re-run
Publish to npm via workflow_dispatch on master with version 0.22.0 — preflight
validates against scripts/version.mjs --current, which is 0.22.0 there, so no re-tag is
needed.

Summary by CodeRabbit

  • Chores
    • Improved the native addon release build process for Alpine-based environments.
    • Standardized build setup, including pinned package and toolchain versions, for more consistent releases.
    • Simplified the publishing workflow by centralizing native build preparation and compilation.

The image bundles Node 18; @napi-rs/cli v3 imports styleText from node:util, which needs 20. Its apk points at edge, whose Node will not relocate against the older base.
@github-actions github-actions Bot added the ci label Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eb651dbd-f473-43f3-aca0-b691f5d11936

📥 Commits

Reviewing files that changed from the base of the PR and between 913d533 and 4080eab.

📒 Files selected for processing (2)
  • .github/scripts/build-node-native-musl.sh
  • .github/workflows/publish-node.yml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • ByteVeda/taskito (manual)

📝 Walkthrough

Walkthrough

The musl Node native-addon build now uses a repository script for Alpine setup, toolchain selection, dependency installation, and compilation. The publish workflow invokes this script inside the configured Docker image.

Changes

Musl native addon build

Layer / File(s) Summary
Configure the Alpine build environment
.github/scripts/build-node-native-musl.sh
The script resolves the repository root, aligns Alpine repositories with the image release, installs build and Node tooling, and prioritizes the installed Node binary.
Install toolchains and build the addon
.github/scripts/build-node-native-musl.sh
The script selects stable Rust, installs the pnpm version from package.json, installs frozen dependencies, and runs the native build.
Invoke the repository build script
.github/workflows/publish-node.yml
The Docker workflow mounts the workspace, preserves Cargo settings, and delegates musl build execution to the repository script.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • ByteVeda/taskito#281: Both changes update the Docker-based musl native-addon build in .github/workflows/publish-node.yml.
  • ByteVeda/taskito#282: Both changes update native addon build environments in .github/workflows/publish-node.yml.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: using a compatible Node.js version for the musl build and napi CLI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@kartikeya-27
kartikeya-27 merged commit e86d32c into master Aug 3, 2026
18 checks passed
@kartikeya-27
kartikeya-27 deleted the fix/node-musl-image-node20 branch August 3, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants