Skip to content

fix(setup): gate dev-shell C++ runtime LD_LIBRARY_PATH injection to NixOS - #704

Merged
c-vigo merged 2 commits into
feature/625-nix-claude-migrationfrom
bugfix/703-ld-library-path-nixos-gate
Jun 25, 2026
Merged

c-vigo merged 2 commits into
feature/625-nix-claude-migrationfrom
bugfix/703-ld-library-path-nixos-gate

Conversation

@c-vigo

@c-vigo c-vigo commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #703. Fixes a regression from #698 that broke every just recipe inside
nix develop on non-NixOS (FHS) hosts
with:

/usr/bin/env: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_ABI_DT_X86_64_PLT' not found
   (required by /nix/store/…-glibc-2.42-67/lib/libm.so.6)

Root cause: #698 exported ${stdenv.cc.cc.lib}/lib (the Nix C++ runtime, linked
against glibc 2.42) onto the dev-shell LD_LIBRARY_PATH unconditionally — so
the pymarkdown pre-commit wheel could resolve libstdc++.so.6. On an FHS host
whose system glibc is older (Ubuntu 24.04 = 2.39), that Nix libstdc++ is
pulled into host binaries — every just recipe runs via #!/usr/bin/env bash,
and on hosts with an /etc/ld.so.preload agent that links libstdc++ it reaches
/usr/bin/env directly — dragging in the Nix libm.so.6, which requires the
GLIBC_ABI_DT_X86_64_PLT symbol version the host's 2.39 libc does not export.
It worked on NixOS only because there the system glibc is the Nix glibc.

Type of Change

  • fix -- Bug fix

Changes Made

  • flake.nix (mkProjectShell): inject the Nix C++ runtime onto LD_LIBRARY_PATH
    only on NixOS ([ -e /etc/NIXOS ]), where it is both required (libstdc++
    is off the default loader path) and ABI-safe (system glibc is the Nix glibc).
    On FHS hosts the system loader already resolves libstdc++, so the injection is
    a no-op and nothing leaks into host binaries.
  • tests/test_flake_devshell.py: the [BUG] pre-commit: make the pymarkdown hook (pyjson5 C-extension / libstdc++) run on NixOS #698 injection-presence tests are gated to
    NixOS, and a new FHS-only test_devshell_no_nix_cxx_runtime_leak_on_fhs_host
    asserts the Nix C++ runtime is not exposed on LD_LIBRARY_PATH (the RED
    anchor for this fix).
  • CHANGELOG.md (+ synced workspace copy): ### Fixed entry.

Changelog Entry

### Fixed

- **Nix dev-shell no longer breaks `just` on non-NixOS hosts (Nix C++ runtime leaked onto `LD_LIBRARY_PATH`)** ([#703](https://github.com/vig-os/devcontainer/issues/703))
  - The #698 fix exported `${stdenv.cc.cc.lib}/lib` (the Nix C++ runtime, linked against glibc 2.42) onto the dev-shell `LD_LIBRARY_PATH` unconditionally. On an FHS host whose system glibc is older (e.g. Ubuntu 24.04 ships 2.39), that `libstdc++` is pulled into host binaries … aborting with `version 'GLIBC_ABI_DT_X86_64_PLT' not found`, so every `just` recipe failed inside `nix develop`
  - `mkProjectShell` now injects the Nix C++ runtime onto `LD_LIBRARY_PATH` only on NixOS (`[ -e /etc/NIXOS ]`) … FHS hosts resolve `libstdc++` from the system loader, so the injection is a no-op there and nothing leaks. The #698 dev-shell parity tests are gated to NixOS and an FHS leak-guard was added

Testing

  • Tests pass locally — pytest tests/test_flake_devshell.py: 8 passed, 2
    skipped
    (the two NixOS-only injection tests skip on this FHS host; the
    leak-guard passes).
  • Manual testing performed (below)

Manual Testing Details

On Ubuntu 24.04 (glibc 2.39), inside nix develop:

  • Before: LD_LIBRARY_PATH carried …/gcc-15.2.0-lib/lib; just build /
    just test-bats aborted with the GLIBC error above.
  • After: LD_LIBRARY_PATH is empty; /usr/bin/env bash runs; just lint passes
    and just build proceeds into the real Nix image build.
  • TDD: the leak-guard test was committed RED first (a818fb7), then the flake
    gate made it GREEN (e27962a).

CI does not auto-run for PRs into the epic branch (ci.yml triggers on PRs to
dev/release/**/main), so the project suite is dispatched manually on
this head branch.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

c-vigo added 2 commits June 25, 2026 12:13
The #698 LD_LIBRARY_PATH libstdc++ injection is only needed and ABI-safe on NixOS. Gate the two injection-presence tests to NixOS and add an FHS-only guard asserting the Nix C++ runtime is not exposed on LD_LIBRARY_PATH (it breaks host binaries with GLIBC_ABI_DT_X86_64_PLT). Fails until the dev-shell gate lands.

Refs: #703
…ixOS

The #698 dev-shell exported the Nix C++ runtime (stdenv.cc.cc.lib, linked against glibc 2.42) onto LD_LIBRARY_PATH unconditionally. On an FHS host with an older system glibc (Ubuntu 24.04 = 2.39) that libstdc++ leaks into host binaries — every just recipe's '#!/usr/bin/env bash', and anything an /etc/ld.so.preload agent pulls libstdc++ into — dragging in the Nix libm.so.6 and aborting with 'GLIBC_ABI_DT_X86_64_PLT not found'. Inject only on NixOS ([ -e /etc/NIXOS ]), where it is both required and ABI-safe; FHS hosts resolve libstdc++ from the system loader, so the injection is a no-op and nothing leaks.

Refs: #703
@c-vigo c-vigo added bug Something isn't working priority:high Should be done in the current milestone area:image Container image, Dockerfile, build semver:patch Bug fix, backward-compatible labels Jun 25, 2026
@c-vigo
c-vigo merged commit 25554b4 into feature/625-nix-claude-migration Jun 25, 2026
10 checks passed
@c-vigo
c-vigo deleted the bugfix/703-ld-library-path-nixos-gate branch June 25, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:image Container image, Dockerfile, build bug Something isn't working priority:high Should be done in the current milestone semver:patch Bug fix, backward-compatible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant