Repository navigation
fix(workspace): scope libstdc++ for uvx native wheels in direnv CI - #1184
Merged
Merged
Conversation
Add bats coverage for a base `with-native-libs` recipe that scopes LD_LIBRARY_PATH to a single uvx/uv-tool command so a nix CPython can load manylinux native wheels under direnv-mode CI. Exercises derivation from the on-PATH cc wrapper, VIGOS_STDCPP_LIB precedence, graceful no-op when the lib is absent, and preservation of an existing LD_LIBRARY_PATH. Fails until the recipe ships. Refs: #1181
On a non-Python direnv-mode consumer the CI preamble keeps the Nix CPython on PATH, whose loader does not search /usr/lib, so a uvx tool's manylinux native wheel (e.g. otterdog's rjsonnet) aborts with "libstdc++.so.6: cannot open shared object file" — the same failure class as the dropped pymarkdown/pyjson5 hook. Add a base `with-native-libs` recipe to the root justfile (reachable in every delivery mode, unlike the devcontainer-only justfile.devc) that wraps one uvx/uv-tool command with a command-scoped LD_LIBRARY_PATH, sourced from $VIGOS_STDCPP_LIB or derived from the on-PATH `cc` wrapper and degrading to a no-op when neither resolves. Mirrors the pattern proven in org-config@f01175a. Refs: #1181
Record the direnv-mode CI fix in the changelog and document the base `with-native-libs` recipe in the Nix runtime notes: when a consumer needs it (uvx/uv-tool tools with native extensions under the Nix CPython), how to wrap an invocation, and how it degrades to a no-op. Refs: #1181
…libs When nothing resolves the libstdc++ dir, the current composition still sets LD_LIBRARY_PATH — empty, or ":/pre/existing" when the caller had one. Either way that adds an empty entry, which the dynamic loader treats as the current working directory, silently putting cwd on the library search path. Assert the caller's value passes through byte-identical (no leading colon) and that with no inherited value the variable stays unset. Fails until the recipe branches on a non-empty prefix. Refs: #1181
The dev-shell environment exports a multi-line shellHook variable whose body contains the literal text LD_LIBRARY_PATH, so the substring refute can never pass regardless of the recipe's behavior. Refute the exact env line (^LD_LIBRARY_PATH=) instead, which still rejects both an empty-set and a leading-colon composition. Refs: #1181
…ve-libs When neither $VIGOS_STDCPP_LIB nor the cc wrapper resolves the libstdc++ dir, the recipe composed the prefix anyway: with the caller's LD_LIBRARY_PATH set it produced ":/pre/existing", and with it unset it set the variable to "". Either way that is an empty search-path entry, which the dynamic loader treats as the current working directory — running a wrapped tool from an untrusted directory could load a planted libstdc++.so.6. Branch on a non-empty prefix and run the command with the environment untouched otherwise. Refs: #1181
The helper now leaves the environment untouched when nothing resolves the libstdc++ dir instead of composing an empty prefix; align the Nix runtime notes with that behavior and record why an empty entry is unsafe. Refs: #1181
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
On a non-Python direnv-mode consumer, the CI preamble keeps the Nix CPython on
PATH(the manylinux exclusion of #1028 only applies whenpyproject.tomlexists). Auvx-run tool whose manylinux native wheel linkslibstdc++.so.6then aborts withlibstdc++.so.6: cannot open shared object file, because the Nix loader does not search/usr/lib— the same failure class as the droppedpymarkdown/pyjson5hook.Fixes #1181.
Approach
Ship the proven org-config pattern as a base justfile helper rather than a global preamble export or a change to
setup-devkit-toolchain(owned by #1180). The rootassets/workspace/justfilegains awith-native-libs +commandrecipe:.devcontainer/justfile.devc) — direnv-mode CI is exactly the case that needs it.LD_LIBRARY_PATHfrom$VIGOS_STDCPP_LIB(dev-shell export) or, failing that, from the on-PATHccwrapper viacc -print-file-name=libstdc++.so.6(the wrapper is on the preamble-forwarded PATH;ccechoes the bare name back — not an absolute path — when it cannot resolve the lib, so the leading-/check degrades to a no-op).libstdc++never leaks into other tools' processes; degrades to the caller's ownLD_LIBRARY_PATH(or empty) when neither source resolves.A consumer recipe wraps its tool:
Provenance & evidence
env -i PATH=<store bins>simulation.tests/bats/just.batsexercises all branches:LD_LIBRARY_PATHfrom the on-PATHccwrapper,$VIGOS_STDCPP_LIBover deriving fromcc,LD_LIBRARY_PATH.bats tests/bats/just.bats: 51/51 pass (5 new).prek run --all-files: fully green.Scope
Minimal diff — root justfile helper, its bats coverage, changelog (+ synced
.devcontainer/mirror), and NIX.md docs. Does not touchsetup-devkit-toolchain(#1180) and does not resurrect the pymarkdown hook (nix-packaged separately in #1177).Review fix: no empty LD_LIBRARY_PATH entries
Review found an edge case: when nothing resolved the libstdc++ dir (no
$VIGOS_STDCPP_LIB,ccabsent or lib not found) the recipe still composed the prefix, yielding:/pre/existingwhen the caller had anLD_LIBRARY_PATH(a leading empty entry = cwd on the dynamic loader's search path — a tool run from an untrusted directory could load a plantedlibstdc++.so.6), or setting the variable to""when it did not. Fixed (TDD, RED then GREEN): the recipe now branches on a non-empty prefix and otherwise runs the command with the environment untouched — never a leading colon, never set-to-empty. New bats coverage asserts the caller's value passes through byte-identical and that the variable stays unset in the pure no-op case. After the fix:bats tests/bats/just.bats52/52 pass,prek run --all-filesfully green.Refs: #1181, vig-os/org-config#40