Skip to content

Commit 42ea64b

Browse files
authored
Musl is too hard to set up on GitHub Actions, removing (#192)
1 parent 1661dc9 commit 42ea64b

6 files changed

Lines changed: 13 additions & 135 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,32 @@ jobs:
1010
name: Build N-API modules
1111
runs-on: ${{ matrix.settings.host }}
1212
permissions: {}
13-
defaults:
14-
run:
15-
shell: ${{ matrix.settings.shell }}
1613
strategy:
1714
fail-fast: false
1815
matrix:
1916
settings:
2017
- host: macos-15-intel
2118
target: x86_64-apple-darwin
2219
npm_platform: darwin-x64
23-
shell: bash
2420
- host: macos-latest
2521
target: aarch64-apple-darwin
2622
npm_platform: darwin-arm64
27-
shell: bash
2823
- host: windows-latest
2924
target: x86_64-pc-windows-msvc
3025
npm_platform: win32-x64-msvc
31-
shell: bash
3226
- host: windows-11-arm
3327
target: aarch64-pc-windows-msvc
3428
npm_platform: win32-arm64-msvc
35-
shell: bash
3629
- host: ubuntu-latest
3730
target: x86_64-unknown-linux-gnu
3831
npm_platform: linux-x64-gnu
39-
shell: bash
4032
- host: ubuntu-24.04-arm
4133
target: aarch64-unknown-linux-gnu
4234
npm_platform: linux-arm64-gnu
43-
shell: bash
44-
- host: ubuntu-latest
45-
target: x86_64-unknown-linux-musl
46-
npm_platform: linux-x64-musl
47-
alpine: true
48-
alpine_arch: x86_64
49-
shell: alpine.sh {0}
50-
- host: ubuntu-latest
51-
target: aarch64-unknown-linux-musl
52-
npm_platform: linux-arm64-musl
53-
alpine: true
54-
alpine_arch: aarch64
55-
shell: alpine.sh {0}
5635
steps:
5736
# Speed up apt-get operations by disabling unnecessary man-db auto-update
5837
- name: Disable man-db auto-update
59-
if: runner.os == 'Linux' && !matrix.settings.alpine
38+
if: runner.os == 'Linux'
6039
run: |
6140
echo "man-db man-db/auto-update boolean false" | sudo debconf-set-selections
6241
sudo rm -f /var/lib/man-db/auto-update
@@ -72,33 +51,11 @@ jobs:
7251
cache: false
7352
- name: Setup Task runner
7453
uses: go-task/setup-task@v1
75-
- name: Setup Alpine Linux
76-
if: matrix.settings.alpine
77-
uses: jirutka/setup-alpine@v1
78-
with:
79-
arch: ${{ matrix.settings.alpine_arch }}
80-
packages: >
81-
build-base
82-
cups-dev
83-
nodejs
84-
npm
85-
go-task
86-
curl
87-
- name: Install Linux dependencies (glibc)
88-
if: runner.os == 'Linux' && !matrix.settings.alpine
54+
- name: Install Linux dependencies
55+
if: runner.os == 'Linux'
8956
run: |
9057
sudo apt-get update
9158
sudo apt-get install -y libcups2-dev pkg-config clang
92-
- name: Install Rust toolchain in Alpine (musl)
93-
if: matrix.settings.alpine
94-
run: |
95-
# Install rustup
96-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
97-
source $HOME/.cargo/env
98-
# Install toolchain and components from rust-toolchain.toml
99-
rustup show
100-
# Add musl target
101-
rustup target add ${{ matrix.settings.target }}
10259
- name: Install dependencies
10360
run: npm ci
10461
- name: Build N-API module
@@ -138,46 +95,27 @@ jobs:
13895
runs-on: ${{ matrix.settings.host }}
13996
needs: build-napi
14097
permissions: {}
141-
defaults:
142-
run:
143-
shell: ${{ matrix.settings.shell }}
14498
strategy:
14599
fail-fast: false
146100
matrix:
147101
settings:
148102
- host: macos-13
149103
target: x86_64-apple-darwin
150-
shell: bash
151104
- host: macos-14
152105
target: aarch64-apple-darwin
153-
shell: bash
154106
- host: windows-latest
155107
target: x86_64-pc-windows-msvc
156-
shell: bash
157108
- host: windows-11-arm
158109
target: aarch64-pc-windows-msvc
159110
test_runtimes: rust node
160-
shell: bash
161111
- host: ubuntu-latest
162112
target: x86_64-unknown-linux-gnu
163-
shell: bash
164113
- host: ubuntu-24.04-arm
165114
target: aarch64-unknown-linux-gnu
166-
shell: bash
167-
- host: ubuntu-latest
168-
target: x86_64-unknown-linux-musl
169-
alpine: true
170-
alpine_arch: x86_64
171-
shell: alpine.sh {0}
172-
- host: ubuntu-latest
173-
target: aarch64-unknown-linux-musl
174-
alpine: true
175-
alpine_arch: aarch64
176-
shell: alpine.sh {0}
177115
steps:
178116
# Speed up apt-get operations by disabling unnecessary man-db auto-update
179-
- name: Disable man-db auto-update and install deps (glibc)
180-
if: runner.os == 'Linux' && !matrix.settings.alpine
117+
- name: Disable man-db auto-update and install deps
118+
if: runner.os == 'Linux'
181119
run: |
182120
echo "man-db man-db/auto-update boolean false" | sudo debconf-set-selections
183121
sudo rm -f /var/lib/man-db/auto-update
@@ -208,27 +146,6 @@ jobs:
208146
with:
209147
version: 3.x
210148
repo-token: ${{ secrets.GITHUB_TOKEN }}
211-
- name: Setup Alpine Linux
212-
if: matrix.settings.alpine
213-
uses: jirutka/setup-alpine@v1
214-
with:
215-
arch: ${{ matrix.settings.alpine_arch }}
216-
packages: >
217-
cups-dev
218-
go-task
219-
nodejs
220-
npm
221-
deno
222-
bun
223-
curl
224-
- name: Install Rust toolchain in Alpine (musl)
225-
if: matrix.settings.alpine
226-
run: |
227-
# Install rustup
228-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
229-
source $HOME/.cargo/env
230-
# Install toolchain and components from rust-toolchain.toml
231-
rustup show
232149
- name: Download all N-API binary artifacts
233150
uses: actions/download-artifact@v5
234151
with:

CLAUDE.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,8 @@ ALWAYS run these after changes through the taskfile:
180180
runtime detection and behavior
181181
10. **Platform limitations**:
182182
- Android intentionally excluded from N-API builds
183-
11. **Musl support**: Linux musl (Alpine) fully supported
184-
- Detection via `process.report` API (no shell/filesystem access)
185-
- Built with Docker using `node:22-alpine` for security
186-
- Supports both x64 and arm64 architectures
187-
12. **Deno N-API support**: Deno requires `"nodeModulesDir": "auto"` in deno.json
183+
- Linux musl (Alpine) not currently supported - only glibc-based distributions
184+
11. **Deno N-API support**: Deno requires `"nodeModulesDir": "auto"` in deno.json
188185
and `--allow-ffi` flag for N-API modules to work
189186

190187
## NAPI-RS Publishing and Release Workflow

CONTRIBUTING.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,10 @@ The GitHub Actions release workflow handles cross-platform builds and npm publis
177177

178178
**Supported platforms:**
179179

180-
- **Linux**: x64-gnu, arm64-gnu, x64-musl, arm64-musl (both glibc and musl supported)
180+
- **Linux**: x64-gnu, arm64-gnu
181181
- **macOS**: x64, arm64
182182
- **Windows**: x64-msvc, arm64-msvc
183183

184-
**Musl Support:** Alpine Linux, BusyBox-based systems, and other musl-based distributions are fully supported. The library automatically detects musl vs glibc using Node.js's `process.report` API.
185-
186184
## Publishing Architecture
187185

188186
**Distribution via npm:**

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Cross-runtime printer library for Node.js, Deno, and Bun with native performance
99
## Features
1010

1111
- 🔄 **Cross-runtime compatibility** - Node.js, Deno, and Bun support
12-
- 🖨️ **Cross-platform printing** - Windows, macOS, and Linux (glibc and musl)
12+
- 🖨️ **Cross-platform printing** - Windows, macOS, and Linux
1313
- 🦀 **Native performance** - Rust backend with Node-API bindings
1414
- 🔒 **Safe testing** - Simulation mode prevents accidental printing
1515
- 📊 **Real-time monitoring** - Printer state changes and job tracking
@@ -20,7 +20,7 @@ Cross-runtime printer library for Node.js, Deno, and Bun with native performance
2020

2121
- **macOS**: x64, arm64
2222
- **Windows**: x64, arm64
23-
- **Linux**: x64, arm64 (both glibc and musl supported, including Alpine Linux)
23+
- **Linux**: x64, arm64
2424

2525
## Installation
2626

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
"x86_64-pc-windows-msvc",
1717
"aarch64-pc-windows-msvc",
1818
"x86_64-unknown-linux-gnu",
19-
"aarch64-unknown-linux-gnu",
20-
"x86_64-unknown-linux-musl",
21-
"aarch64-unknown-linux-musl"
19+
"aarch64-unknown-linux-gnu"
2220
]
2321
},
2422
"engines": {

src/index.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -734,35 +734,6 @@ if (isSimulationMode) {
734734
);
735735
}
736736

737-
/**
738-
* Detect if the system is using musl libc (e.g., Alpine Linux)
739-
* Uses process.report API which is available in Node.js without filesystem/shell access
740-
*/
741-
function isMuslLibc(): boolean {
742-
if (!isNode) return false;
743-
744-
try {
745-
// Check for glibc version in process report (only present on glibc systems)
746-
const report = g.process?.report?.getReport?.();
747-
if (report?.header?.glibcVersionRuntime) {
748-
return false; // Has glibc version, so it's glibc
749-
}
750-
751-
// Check shared objects for musl indicators
752-
if (Array.isArray(report?.sharedObjects)) {
753-
return report.sharedObjects.some(
754-
(obj: string) =>
755-
typeof obj === "string" &&
756-
(obj.includes("libc.musl-") || obj.includes("ld-musl-"))
757-
);
758-
}
759-
} catch {
760-
// If report API fails, assume glibc (safer default)
761-
}
762-
763-
return false;
764-
}
765-
766737
// Always load the N-API module - let the backend handle simulation mode
767738
try {
768739
// Platform detection for N-API module loading
@@ -788,13 +759,10 @@ try {
788759
throw new Error(`Unsupported architecture for Windows: ${arch}`);
789760
}
790761
} else if (platform === "linux") {
791-
// Detect musl vs glibc
792-
const isMusl = isMuslLibc();
793-
794762
if (arch === "x64") {
795-
platformString = isMusl ? "linux-x64-musl" : "linux-x64-gnu";
763+
platformString = "linux-x64-gnu";
796764
} else if (arch === "arm64") {
797-
platformString = isMusl ? "linux-arm64-musl" : "linux-arm64-gnu";
765+
platformString = "linux-arm64-gnu";
798766
} else {
799767
throw new Error(`Unsupported architecture for Linux: ${arch}`);
800768
}

0 commit comments

Comments
 (0)