Skip to content

fix nix libffi.so.7 breakage, restore swarm CLI - #1

Open
mggpie wants to merge 1 commit into
mainfrom
mggpie-fix-nix-libffi-swarm
Open

mggpie wants to merge 1 commit into
mainfrom
mggpie-fix-nix-libffi-swarm

Conversation

@mggpie

@mggpie mggpie commented Jun 21, 2026

Copy link
Copy Markdown
Owner

libffi.so.7 was garbage-collected from the nix store. nix, bun, and opencode all use the nix glibc linker which only searches nix store paths — so they all failed silently with libffi.so.7: cannot open shared object file, making opencode (and swarm) completely non-functional.

Root cause: nix store GC removed the libffi-3.3.x derivation (which provides .so.7). The nix store now only has libffi-3.4/3.5.x (.so.8). The nix glibc linker doesn't fall back to /usr/lib, so it can't find the file even though it exists there.

Fix: create ~/.local/share/nix-compat/ with a single symlink to the system /usr/lib/libffi.so.7. That directory contains only libffi.so.7, so no other system libs can bleed in and cause ABI crashes.

  • env.fish: set LD_LIBRARY_PATH to the shim dir on shell startup
  • swarm.ts: inject LD_LIBRARY_PATH into PTY env and bashSpawn env so the swarm CLI works even when the env isn't inherited from an interactive fish session
  • opencode.yml: create the shim dir/symlink as a prerequisite, add LD_LIBRARY_PATH to the nix shell task
  • opencode-swarm.yml: same env fix for the bun install task
  • nixgl.yml: same env fix for the nixGL install task

Verified: swarm tool swarmmail_health returns {"success":true,"data":{"healthy":true,...}}. opencode --version and bun --version both work with the shim in place.

libffi.so.7 was garbage-collected from the nix store. nix, bun, and
opencode all use the nix glibc linker which only searches nix store
paths - so they all failed with 'libffi.so.7: cannot open shared
object file', making opencode (and swarm) completely non-functional.

Fix: create ~/.local/share/nix-compat/ with a single symlink to the
system /usr/lib/libffi.so.7. That dir contains only libffi.so.7, so
no other system libs bleed in and cause ABI crashes.

- env.fish: set LD_LIBRARY_PATH to the shim dir on shell startup
- swarm.ts: inject LD_LIBRARY_PATH into PTY env and bashSpawn env
- opencode.yml: create the shim dir/symlink, pass LD_LIBRARY_PATH
  to the nix shell task
- opencode-swarm.yml: same env fix for bun install task
- nixgl.yml: same env fix for nixGL install task

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 21, 2026 16:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses Nix runtime breakage caused by libffi.so.7 being garbage-collected from the Nix store by introducing a minimal compatibility shim (~/.local/share/nix-compat/libffi.so.7) and ensuring relevant tooling (OpenCode, swarm, bun, nixGL) can find it via LD_LIBRARY_PATH.

Changes:

  • Add Ansible provisioning for the nix-compat shim and propagate LD_LIBRARY_PATH to Nix-driven install tasks.
  • Inject LD_LIBRARY_PATH into the OpenCode swarm plugin process environments so the swarm CLI works even when not launched from an interactive Fish session.
  • Update Fish startup env to prepend the shim directory to LD_LIBRARY_PATH when present.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
roles/dotfiles/tasks/opencode.yml Creates the nix-compat shim and sets LD_LIBRARY_PATH during opencode install.
roles/dotfiles/tasks/opencode-swarm.yml Sets LD_LIBRARY_PATH for bun install used by the swarm CLI runtime.
roles/dotfiles/tasks/nixgl.yml Sets LD_LIBRARY_PATH for nixGL install.
roles/dotfiles/files/opencode/plugin/swarm.ts Injects LD_LIBRARY_PATH into PTY and spawn env to keep swarm functional outside interactive shells.
roles/dotfiles/files/fish/conf.d/env.fish Prepends ~/.local/share/nix-compat to LD_LIBRARY_PATH on shell startup when available.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +17
- name: Symlink system libffi.so.7 into nix compat shim
ansible.builtin.file:
src: /usr/lib/libffi.so.7
dest: "{{ user_home }}/.local/share/nix-compat/libffi.so.7"
state: link
Comment on lines +39 to +40
environment:
LD_LIBRARY_PATH: "{{ user_home }}/.local/share/nix-compat"
Comment on lines +19 to +20
environment:
LD_LIBRARY_PATH: "{{ user_home }}/.local/share/nix-compat"
Comment on lines +619 to +621
// libffi.so.7 was GC'd from the nix store; shim dir contains only that one symlink
// so it can't pollute other nix-linked libs with incompatible system versions.
LD_LIBRARY_PATH: `/home/me/.local/share/nix-compat:${process.env.LD_LIBRARY_PATH || ""}`,
env: {
...process.env,
PATH: `/home/me/.nix-profile/bin:/usr/bin:/usr/local/bin:${process.env.PATH || ""}`,
LD_LIBRARY_PATH: `/home/me/.local/share/nix-compat:${process.env.LD_LIBRARY_PATH || ""}`,

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants