Problem
The stylua pre-commit hook in .pre-commit-config.yaml is the upstream JohnnyMorganz/StyLua hook, which installs stylua via cargo install from source. This requires a working Rust toolchain including a system C linker (cc).
On hosts without cc (notably TrueNAS appliances where apt is disabled), the hook env install fails with:
error: linker `cc` not found
error: could not compile `proc-macro-error-attr` (build script) due to 1 previous error
…
error: failed to compile `stylua v2.1.0`
This blocks every commit from such hosts, even commits that don't touch any Lua files (pre-commit installs hook envs eagerly on first use).
Workaround in use: SKIP=stylua git commit … per commit.
Why
The dotfiles repo only has a few Lua files (Neovim config). It's not worth requiring a full Rust + C toolchain on every machine that wants to commit changes — especially on minimal Linux hosts where the user can't apt install build-essential.
What
Swap the stylua pre-commit hook to a variant that uses a prebuilt binary instead of building from source. Two viable options:
pre-commit-stylua (JohnnyMorganz/StyLua#stylua-prebuilt ships an alternative hook id) — the official prebuilt-binary hook, downloads a release asset.
- Local hook invoking
stylua from \$PATH, with stylua installed via mise/aqua/brew on each platform.
Option 1 keeps the workflow uniform across machines without per-host install. Option 2 reuses the mise-managed binary if we add it.
How
Edit .pre-commit-config.yaml:
# Before
- repo: https://github.com/JohnnyMorganz/StyLua
rev: v2.1.0
hooks:
- id: stylua
# After (option 1 — prebuilt)
- repo: https://github.com/JohnnyMorganz/StyLua
rev: v2.1.0
hooks:
- id: stylua-system # or stylua-prebuilt — verify exact id from upstream
Verify by:
- Removing the existing pre-commit hook env (
pre-commit clean or rm -rf ~/.cache/pre-commit/repo*)
- Running
pre-commit run stylua --all-files on TrueNAS with no cc available — it should succeed.
- Running on macOS to confirm parity.
Related
Problem
The
styluapre-commit hook in.pre-commit-config.yamlis the upstream JohnnyMorganz/StyLua hook, which installs stylua viacargo installfrom source. This requires a working Rust toolchain including a system C linker (cc).On hosts without
cc(notably TrueNAS appliances whereaptis disabled), the hook env install fails with:This blocks every commit from such hosts, even commits that don't touch any Lua files (pre-commit installs hook envs eagerly on first use).
Workaround in use:
SKIP=stylua git commit …per commit.Why
The dotfiles repo only has a few Lua files (Neovim config). It's not worth requiring a full Rust + C toolchain on every machine that wants to commit changes — especially on minimal Linux hosts where the user can't
apt install build-essential.What
Swap the stylua pre-commit hook to a variant that uses a prebuilt binary instead of building from source. Two viable options:
pre-commit-stylua(JohnnyMorganz/StyLua#stylua-prebuilt ships an alternative hook id) — the official prebuilt-binary hook, downloads a release asset.styluafrom\$PATH, withstyluainstalled via mise/aqua/brew on each platform.Option 1 keeps the workflow uniform across machines without per-host install. Option 2 reuses the mise-managed binary if we add it.
How
Edit
.pre-commit-config.yaml:Verify by:
pre-commit cleanorrm -rf ~/.cache/pre-commit/repo*)pre-commit run stylua --all-fileson TrueNAS with noccavailable — it should succeed.Related
SKIP=styluabecause of this issue.