Repository navigation
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Same bug here on the v2.0.24 tag built with One concern with the wrapper route: Patching the addon itself avoids that. We do it after postConfigure = lib.optionalString stdenvNoCC.hostPlatform.isLinux ''
for addon in node_modules/.bun/@parcel+watcher-linux-*-glibc@*/node_modules/@parcel/watcher-linux-*-glibc/watcher.node; do
chmod u+w "$addon"
patchelf --add-rpath ${lib.makeLibraryPath [ stdenv.cc.cc.lib ]} "$addon"
bun -e 'require(process.argv[1])' "$PWD/$addon" # fails the build if it still can't load
done
'';(with |
Right, I thought I mentioned it. 😬
Who is 'We' In this context? I don't see this change in the repo, are you talking about another project? |
|
Sorry, that was unclear: "we" is my own NixOS config. It builds OpenCode from the v2.0.24 tag with this repo's flake package and adds that For transparency: an AI agent is managing this change on my side. |
|
Hello, I have an update ready based on what @nkoynov suggested, with additional check to ensure the patch is applied & useful. |
The glibc `@parcel/watcher` addon links libstdc++ without a RUNPATH, so the load fails and every directory watch dies (see anomalyco#53210). Patch it in `postConfigure`, before `buildPhase` embeds it into the standalone library binary. Keeping the fix in the addon avoids putting libstdc++ on `LD_LIBRARY_PATH`, which every spawned process would inherit and which outranks that program's own RUNPATH. The dev shell keeps its own libstdc++ export, limited to Linux.
f6d9a9a to
c1afe3a
Compare
|
Tested c1afe3a on NixOS x86_64: built it and its merge base (69269e4) with nix/opencode.nix and ran each as a throwaway |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
|
(I'll post the reply myself, in case the bot only react if the author replies) This is still needed: For me the PR is ready for review/merge. 👉 Could it be reopened? and get a review for merge? |
Issue for this PR
Closes #53210
Type of change
What does this PR do?
On NixOS the packaged
opencodenever loads its native filesystem watcher.The bundled
@parcel/watcheraddon is a prebuilt.nodethat linkslibstdc++.so.6dynamically and has no RUNPATH, so the loader can't resolve the C++ runtime and thedlopenis dropped quietly.In practice this shows up as skills and config edits never reloading: recursive directory watches (
type:directory, parcel-backed) go silent, while the per-file watches (type:file/entries, which use node'sfs.watch) keep working.The Nix wrapper's
LD_LIBRARY_PATHonly carriedwayland, and the devshell had no libstdc++ at all, sobun devfrom the devshell failed the same way.This adds
stdenv.cc.cc.libin both places so the addon resolves the C++ runtime when it loads.Note
numtide's
llm-agents.nixtakes a different route inpackages/opencode2/package.nix: it patches the wrapped binary'sDT_RPATHwithformatelfso the executable itself resolveslibstdc++, and vendorsformatelfbecause it isn't in nixpkgs.I kept the wrapper approach here:
formatelfwould pull a new packaged tool (and its setup hook) into this repo, plainpatchelf --force-rpathcorrupts this bun standalone (it segfaults on launch), and the wrapper already setsLD_LIBRARY_PATHforwayland— so extending it is the smaller, single-place change.How did you verify your code works?
I reproduced it by hand first:
readelf -d watcher.nodeshowsNEEDED libstdc++.so.6and no RPATH, and a plainbunrequireof the addon fails in a clean env but loads once the gcc lib dir is onLD_LIBRARY_PATH.Then I built the package (
nix build .#opencode) and ran the wrapped binary understrace.The embedded addon is extracted to
/tmp/.bun-<uid>-<hash>.node(sha256 matches@parcel/[email protected]/watcher.node), and thelibstdc++.so.6lookup now resolves from the added gcc lib dir instead of returningENOENT.I didn't run the JS test suite for this — it's a Nix packaging change only.
Checklist