Skip to content

claude-code: use DT_RPATH for alsa-lib instead of LD_LIBRARY_PATH - #569098

Closed
markus1189 wants to merge 1 commit into
NixOS:masterfrom
markus1189:claude-code-alsa-rpath
Closed

markus1189 wants to merge 1 commit into
NixOS:masterfrom
markus1189:claude-code-alsa-rpath

Conversation

@markus1189

@markus1189 markus1189 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

The claude-code wrapper prefixes LD_LIBRARY_PATH with alsa-lib (added in dbacac5 for voice mode). Every child process inherits it, e.g. commands run by the Bash tool. If claude-code comes from a newer nixpkgs than the rest of the system, system binaries that load libasound fail:

ffmpeg: /nix/store/…-glibc-2.42-84/lib/libm.so.6: version `GLIBC_2.43' not found (required by /nix/store/…-alsa-lib-1.2.16.1/lib/libasound.so.2)

This PR drops the LD_LIBRARY_PATH prefix and lets autoPatchelf add alsa-lib to the binary's DT_RPATH (runtimeDependencies with patchelfFlags = [ "--force-rpath" ]).

Adding the rpath relocates .gnu.version_d, but patchelf does not update DT_VERDEF (NixOS/patchelf#664). ld.so then walks the clobbered old copy and segfaults in _dl_check_map_versions on aarch64-linux; x86_64-linux has the same stale pointer and only works because the old bytes happen to survive. The package therefore puts patchelf with the unmerged fix (NixOS/patchelf#665), backported to 0.15.2, into nativeBuildInputs, where autoPatchelf picks it up; the override can go once nixpkgs' patchelf includes it.

The install check asserts DT_RPATH: a DT_RUNPATH would not reach the dlopen'd module and break voice mode silently.

The fix stays local rather than going into patchelf (stdenv mass rebuild) or patchelfUnstable (its other users would change behaviour without a review of their own). As claude-code is unfree, Hydra does not build the patched patchelf; it is built locally, which is cheap.

Voice mode (hold-to-talk) tested on my machine with this build: recording worked.

Things done

This PR (investigation, change and description) was prepared with Claude Code and reviewed by me.

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. llm-assisted Contributions that include code generation with LLMs labels Oct 1, 2026
@markus1189
markus1189 force-pushed the claude-code-alsa-rpath branch 3 times, most recently from 9c2f8f2 to c21766c Compare October 1, 2026 18:31
@markus1189

Copy link
Copy Markdown
Contributor Author

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (a0a3a8d)

Command: nixpkgs-review pr 569098
Commit: c21766c62947814e8d27948dc23788c06fee459e (subsequent changes)
Merge: fb6341837788bfbd6cb946d348819d0e05626de4

Logs: https://github.com/markus1189/nixpkgs-review-gha/actions/runs/36907545050/attempts/1


x86_64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

x86_64-darwin

✅ No rebuilds


aarch64-darwin (sandbox = relaxed)

✅ 2 packages built:
  • claude-agent-acp
  • claude-code

DataHearth added a commit to DataHearth/nix-config that referenced this pull request Oct 5, 2026
The nixpkgs claude-code wrapper and the local claude-desktop wrapper both
prefixed LD_LIBRARY_PATH, which every Bash tool call inherited: devshells
on an older glibc could no longer start ffmpeg or chromium (`GLIBC_2.43`
not found via alsa-lib's libasound).

claude-code: drop the prefix and put alsa-lib on .claude-wrapped's DT_RPATH
instead, mirroring NixOS/nixpkgs#569098. The embedded audio-capture.node
has no RUNPATH, and glibc only falls back to the executable's DT_RPATH.

claude-desktop: drop the prefix outright. ANGLE is linked into the main
executable, whose RUNPATH already carries libglvnd; LD_DEBUG confirms
libEGL.so.1 and the mesa driver load without it.
@markus1189
markus1189 force-pushed the claude-code-alsa-rpath branch from c21766c to c268f05 Compare October 5, 2026 14:02
@markus1189

Copy link
Copy Markdown
Contributor Author

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (05a4e6e)

Command: nixpkgs-review pr 569098
Commit: c268f05067f75bb7851b59e05c41f47ac7222410 (subsequent changes)
Merge: 2791aec70fd2dad553dedb5bf76c9060698d19d0

Logs: https://github.com/markus1189/nixpkgs-review-gha/actions/runs/37321768823/attempts/1


x86_64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

x86_64-darwin

✅ No rebuilds


aarch64-darwin (sandbox = relaxed)

✅ 2 packages built:
  • claude-agent-acp
  • claude-code

@markus1189
markus1189 force-pushed the claude-code-alsa-rpath branch from c268f05 to e5f384a Compare October 5, 2026 14:27
@markus1189

Copy link
Copy Markdown
Contributor Author

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (05a4e6e)

Command: nixpkgs-review pr 569098
Commit: e5f384ae706233f81268c3908d035784b1ae593a (subsequent changes)
Merge: b6f3b3b4f3236676a0e0324966257e5f7ddab072

Logs: https://github.com/markus1189/nixpkgs-review-gha/actions/runs/37325377255/attempts/1


x86_64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

x86_64-darwin

✅ No rebuilds


aarch64-darwin (sandbox = relaxed)

✅ 2 packages built:
  • claude-agent-acp
  • claude-code

@markus1189
markus1189 force-pushed the claude-code-alsa-rpath branch from e5f384a to dd22a02 Compare October 5, 2026 15:27
@markus1189

Copy link
Copy Markdown
Contributor Author

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (05a4e6e)

Command: nixpkgs-review pr 569098
Commit: dd22a0238c2bef367c49e5931ab759a0ecb0e06d (subsequent changes)
Merge: 5b18f028874eb70957fe7f0aefb6aaf609afe074

Logs: https://github.com/markus1189/nixpkgs-review-gha/actions/runs/37346691116/attempts/1


x86_64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

x86_64-darwin

✅ No rebuilds


aarch64-darwin (sandbox = relaxed)

✅ 2 packages built:
  • claude-agent-acp
  • claude-code

@markus1189
markus1189 force-pushed the claude-code-alsa-rpath branch from dd22a02 to 6eb859a Compare October 5, 2026 17:37
@markus1189

Copy link
Copy Markdown
Contributor Author

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (05a4e6e)

Command: nixpkgs-review pr 569098
Commit: 6eb859a8f491556e2b609cd31afa8ad269795cab (subsequent changes)
Merge: a919befff59eeb7ad4a9f374a0011f8ad6a5bbd5

Logs: https://github.com/markus1189/nixpkgs-review-gha/actions/runs/37349825953/attempts/1


x86_64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

x86_64-darwin

✅ No rebuilds


aarch64-darwin (sandbox = relaxed)

✅ 2 packages built:
  • claude-agent-acp
  • claude-code

@markus1189
markus1189 marked this pull request as ready for review October 5, 2026 17:54
@mirkolenz

Copy link
Copy Markdown
Member

I tested some variants of the derivation locally with the help of Claude and it seems that most of the things can be done through runtimeDependencies and patchelfFlags without disabling autoPatchelf: mirkolenz/infra@7643e32

I also unified isElf and isLinux in my derivation as it's basically the same for this binary package and leads to some simplification. Currently I don't have a linux machine that's capable of testing voice input inside Claude Code directly, but the install check seems to work as expected. Does it solve your issue? What do you think about this version?

@markus1189
markus1189 force-pushed the claude-code-alsa-rpath branch from 6eb859a to 6d8bc70 Compare October 6, 2026 10:13
@markus1189

Copy link
Copy Markdown
Contributor Author

Thanks, that's simpler. I switched the PR to your version and added you as co-author.

I checked that autoPatchelf really calls the patched patchelf from nativeBuildInputs: with it, DT_VERDEF matches .gnu.version_d on x86_64 and aarch64 (cross build, run under qemu). Without it the pointer goes stale and the aarch64 binary segfaults. I kept the stricter install check (readelf -dW, matching (RPATH), no grep -q under pipefail); a build without --force-rpath fails it as intended.

Voice mode works on x86_64-linux with the new build.

@markus1189

Copy link
Copy Markdown
Contributor Author

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (af6a071)

Command: nixpkgs-review pr 569098
Commit: 6d8bc70c147465e4c2938eda84b28574ede9c4a7 (subsequent changes)
Merge: 98dcb32195fcecf8acf2ef9b79bd40bcd33b70b5

Logs: https://github.com/markus1189/nixpkgs-review-gha/actions/runs/37449247936/attempts/1


x86_64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

x86_64-darwin

✅ No rebuilds


aarch64-darwin (sandbox = relaxed)

✅ 2 packages built:
  • claude-agent-acp
  • claude-code

@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Oct 6, 2026
@nixpkgs-ci nixpkgs-ci Bot added the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. label Oct 6, 2026
@markus1189
markus1189 force-pushed the claude-code-alsa-rpath branch from 6d8bc70 to cc3fa55 Compare October 6, 2026 17:13
@markus1189

Copy link
Copy Markdown
Contributor Author

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (af6a071)

Command: nixpkgs-review pr 569098
Commit: cc3fa55101a1ee9af1c8881f64d6b7ac9da64aac (subsequent changes)
Merge: 41b5a7b62e0b64281918cc28e710231910ec5c27

Logs: https://github.com/markus1189/nixpkgs-review-gha/actions/runs/37502679005/attempts/1


x86_64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

x86_64-darwin

✅ No rebuilds


aarch64-darwin (sandbox = relaxed)

✅ 2 packages built:
  • claude-agent-acp
  • claude-code

@markus1189
markus1189 force-pushed the claude-code-alsa-rpath branch from cc3fa55 to 5f4e762 Compare October 7, 2026 05:54
@markus1189

Copy link
Copy Markdown
Contributor Author

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (af6a071)

Command: nixpkgs-review pr 569098
Commit: 5f4e762660871d64b1cf90623f53b86d30f37992 (subsequent changes)
Merge: 0d83df6be8782722e6b83cd93b63bd2f61a1d2f7

Logs: https://github.com/markus1189/nixpkgs-review-gha/actions/runs/37578710719/attempts/1


x86_64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-darwin (sandbox = relaxed)

✅ 2 packages built:
  • claude-agent-acp
  • claude-code

LD_LIBRARY_PATH leaked into child processes and broke system binaries
loading libasound when glibc versions differ.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-authored-by: Mirko Lenz <[email protected]>
@markus1189
markus1189 force-pushed the claude-code-alsa-rpath branch from 5f4e762 to b27c125 Compare October 13, 2026 05:47
@markus1189

Copy link
Copy Markdown
Contributor Author

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (c28ca54)

Command: nixpkgs-review pr 569098
Commit: b27c125a44fc7875026183e59d89eca0ffe1a948 (subsequent changes)
Merge: 2f337c3e897101e71b9c80536f7df250242f2cec

Logs: https://github.com/markus1189/nixpkgs-review-gha/actions/runs/38353203195/attempts/1


x86_64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-linux

✅ 2 packages built:
  • claude-code
  • claude-agent-acp

aarch64-darwin (sandbox = relaxed)

✅ 2 packages built:
  • claude-agent-acp
  • claude-code

typedrat added a commit to typedrat/nix-config that referenced this pull request Oct 16, 2026
…69098)

The wrapper prefixes LD_LIBRARY_PATH with alsa-lib, which every child
process inherits. Linking it through the binary's rpath keeps it out of
the environment.
@markus1189

Copy link
Copy Markdown
Contributor Author

Closing: this no longer works with current releases. Adding any DT_RPATH to the binary (this version, the earlier --add-rpath pass, with or without the patched patchelf) makes patchelf grow the first LOAD segment (0x300 → 0x12260) into the next one at offset 0x128c, and ld.so segfaults in dl_main before main (x86_64, 2.1.304 rebased onto master). Patching just audio-capture.node isn't possible either: it's embedded in Bun's $bunfs with no slack in .dynstr/.dynamic. Thanks @mirkolenz for the review.

@markus1189 markus1189 closed this Oct 22, 2026
typedrat added a commit to typedrat/nix-config that referenced this pull request Oct 24, 2026
The claude-code 2.1.301-2.1.303 bumps (NixOS/nixpkgs#574646, #575166,
#575849) are all in the locked nixpkgs. NixOS/nixpkgs#569098 was closed
unmerged: any DT_RPATH on current claude-code builds makes ld.so segfault,
so the alsa-lib LD_LIBRARY_PATH wrapper is back to upstream's.

synapdeck's determinate now follows ours instead of pinning 3.22.5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants