Repository navigation
Description
[agent] Filed by the architecture refactor routine. Found on main at cfc870f by running scripts/install.sh against a local copy of a release; the Debian run below is a real 32-bit userland in Docker.
Problem
The installer the README tells people to pipe into a shell has two defects that meet on the same machines:
- It reports success for a binary that cannot start. After copying the binary it prints
Installed socket-patch to …, runssocket-patch --versionwith stderr discarded and the exit status ignored (scripts/install.sh, line 174:--version 2>/dev/null || true), and exits 0. When the binary cannot start, the only sign is a version line that is not there. - It picks the build by the kernel, not by the userland, and never picks Android. The target comes from
uname -sanduname -m(lines 43 to 91). A 32-bit userland on a 64-bit kernel answersx86_64oraarch64, so it gets the 64-bit glibc build, whose loader that userland does not have. Termux answersLinuxandaarch64and gets the same glibc build. The release publishes the right asset for each (i686-unknown-linux-gnu,arm-unknown-linux-gnueabihf,aarch64-linux-android), and the script's ownarmv7landi686arms are never reached there.
Who it hurts: anyone who installs with the one-liner on a 32-bit Debian or Ubuntu image on an x86-64 host, on 32-bit Raspberry Pi OS on a board that boots the 64-bit kernel, on Termux, or into a directory mounted noexec. The install step of their script or CI job passes, and the first socket-patch command later fails with not found or Permission denied for a file that exists. docs/ecosystems.md (lines 5739 to 5748) lists i686 Linux, 32-bit ARM Linux and ARM64 Android as supported platforms, and the README offers the installer for "macOS or Linux".
The other two selectors
Three places choose a release build for a machine. The installer is the one that disagrees:
| Selector | Chooses by | Android | A binary that cannot start |
|---|---|---|---|
socket-patch --update |
the running binary's own target (SOCKET_PATCH_TARGET, crates/socket-patch-cli/build.rs) |
yes | not applicable |
the npm launcher (npm/socket-patch/bin/socket-patch) |
process.platform and process.arch, the userland Node runs in |
android arm64 |
tries the next candidate, then prints the spawn error and exits 1 (lines 46 to 73) |
scripts/install.sh |
uname -s and uname -m, the kernel |
no arm for it | prints Installed, exits 0 |
The launcher's handling is a fix of this same class: 8cf1910 (#974, #976), "Fix npm wrapper running the glibc binary on musl". Its message says the wrapper "exited 1 without printing anything" and now "prints the spawn error instead of exiting silently". The launcher's comment calls its musl probe the "same probe as scripts/install.sh"; the fix did not reach the script.
CI already works around the first defect: each installer step in .github/workflows/ci.yml (lines 235 to 277) runs socket-patch --version itself after the script, because the script's exit status does not say whether the binary runs.
Evidence
A release directory served on loopback (<base>/latest/download/socket-patch-x86_64-unknown-linux-gnu.tar.gz holding the binary built from main, and its SHA256SUMS), and SOCKET_PATCH_BASE_URL pointed at it.
A 32-bit Debian userland on a 64-bit kernel
docker run --platform linux/386 --network host buildpack-deps:bookworm-curl, with the script mounted:
$ uname -m; getconf LONG_BIT; dpkg --print-architecture
x86_64
32
i386
$ sh install.sh; echo exit $?
Downloading socket-patch-x86_64-unknown-linux-gnu.tar.gz...
Downloading SHA256SUMS...
Installed socket-patch to /usr/local/bin/socket-patch
exit 0
$ socket-patch --version; echo exit $?
sh: 1: socket-patch: not found
exit 127
The binary asks for /lib64/ld-linux-x86-64.so.2; the image has /lib/ld-linux.so.2 and no /lib64. The fifth byte of that image's /bin/dash is 01 (a 32-bit ELF), and 02 on debian:bookworm-slim for x86-64.
A noexec install directory, on the x86-64 host
$ mount -t tmpfs -o noexec tmpfs nx
$ SOCKET_PATCH_INSTALL_DIR=nx/bin sh scripts/install.sh; echo exit $?
Downloading socket-patch-x86_64-unknown-linux-gnu.tar.gz...
Downloading SHA256SUMS...
Installed socket-patch to nx/bin/socket-patch
exit 0
$ nx/bin/socket-patch --version; echo exit $?
bash: line 1: nx/bin/socket-patch: Permission denied
exit 126
An archive whose socket-patch is 4 KiB of random bytes, or an ARM64 ELF header, gives the same two lines and exit 0.
The asset chosen for Termux and for 32-bit Raspberry Pi OS
Not run on those devices. With a uname first on PATH that answers what each one answers (Linux, aarch64, and Android or GNU/Linux for -o), the script asks for:
Downloading socket-patch-aarch64-unknown-linux-gnu.tar.gz...
The launcher's table for the same machines: android arm64 is @socketsecurity/socket-patch-android-arm64, and linux arm is @socketsecurity/socket-patch-linux-arm-gnu then -musl.
What the script does get right
Run the same way: a 404 for the archive or for SHA256SUMS, a checksum that does not match, a SHA256SUMS with no line for the archive, an HTML page with status 200 in place of either file, and an archive with no socket-patch in it each exit non-zero with nothing installed.
Planned fix
In scripts/install.sh, with no change to the release:
- Choose by the userland. When
uname -msaysx86_64oraarch64, read the ELF class byte of the running shell (/proc/self/exe, as rustup's installer does); a 32-bit class selects thei686or thearm-…-gnueabihftarget, with the libc suffix as detected today. - Choose
aarch64-linux-androidwhenuname -osaysAndroidonaarch64, and say that there is no prebuilt binary for any other Android architecture. - Run
--versionon the installed binary with its stderr shown. When it fails, say that the binary installed for<target>cannot start here, and exit non-zero, as the launcher does. The file stays where it was installed, so the message can name it. - A test in CI's installer step: the script against a local release directory whose binary cannot start must exit non-zero, and the 32-bit Debian image must get the
i686asset.
install.socket.dev serves a copy of this script from a pinned commit, so the fix is live only after that pin is moved (docs/installer-hosting.md).
One point for a maintainer: the exit status of the installer changes from 0 to non-zero for an install whose binary cannot start. The launcher already behaves that way, and CI's own steps assume it; a job that today passes its install step and never runs socket-patch would start to fail there.
Not run: Termux and a Raspberry Pi themselves, a 32-bit Alpine image (the script would pick the static x86-64 musl build, which a 64-bit kernel can start), macOS, and the released binaries (this sandbox served a binary built from main).
Generated by Claude Code
Activity
refactor: #2371 filed; the installer ran