Claude Code crashes with SIGKILL on macOS Mojave when processing images (sharp/libvips _aligned_alloc)
Claude Code crashes with SIGKILL on macOS Mojave when processing images (sharp/libvips _aligned_alloc)
Summary
Claude Code is killed by the dynamic linker (dyld) on macOS Mojave (10.14) whenever it attempts to process an image — for example when dragging an image into the terminal or using vision/screenshot features. The process receives SIGKILL (signal 9) with no opportunity for graceful error handling.
Environment
- macOS: Mojave 10.14.6 (Darwin 18.7.0)
- Claude Code: 2.1.63 (installed globally via npm)
- Node.js: v20.20.0
- npm: 10.8.2
- Architecture: x86_64
Error output
dyld: lazy symbol binding failed: Symbol not found: _aligned_alloc
Referenced from: /usr/local/lib/node_modules/@anthropic-ai/claude-code/node_modules/@img/sharp-darwin-x64/lib/../sharp-libvips-darwin-x64/lib/libvips-cpp.8.17.3.dylib
(which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _aligned_alloc
Referenced from: /usr/local/lib/node_modules/@anthropic-ai/claude-code/node_modules/@img/sharp-darwin-x64/lib/../sharp-libvips-darwin-x64/lib/libvips-cpp.8.17.3.dylib
(which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
Killed: 9
Root cause
Claude Code depends on sharp for image processing. The bundled dependency chain is:
@anthropic-ai/claude-code
└── @img/sharp-darwin-x64 (latest)
└── @img/sharp-libvips-darwin-x64 (latest)
└── libvips-cpp.8.17.3.dylib ← built with MACOSX_DEPLOYMENT_TARGET=10.15
The pre-built libvips-cpp.8.17.3.dylib references _aligned_alloc, a C11 standard library function that was added to macOS in Catalina (10.15). On Mojave (10.14) and earlier, this symbol does not exist in /usr/lib/libSystem.B.dylib.
When dyld encounters the missing symbol at load time, it has no fallback — it kills the process with SIGKILL. This is a native-level crash that cannot be caught by any JavaScript error handler, try/catch, or process.on('uncaughtException').
Why a DYLD shim doesn't work
We attempted to provide _aligned_alloc via a custom shared library injected with DYLD_INSERT_LIBRARIES. macOS Library Validation rejects unsigned dylibs:
aligned_alloc_shim.dylib: code signature not valid for use in process using Library Validation:
mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
The crash still occurs after the shim rejection. This approach is not viable without additional code-signing steps that are impractical as a user-facing workaround.
User workaround
Downgrade the sharp native binary to version 0.33.0, which pulls in @img/sharp-libvips-darwin-x64@1.0.0 containing an older libvips built for macOS 10.13+ (no _aligned_alloc dependency):
# Run from the directory where claude-code is installed globally
sudo npm i @img/sharp-darwin-x64@0.33.0
Verify:
npm list @img/sharp-libvips-darwin-x64
# Should show @img/sharp-libvips-darwin-x64@1.0.0
Note: This must be re-applied after every Claude Code upgrade, as npm update -g @anthropic-ai/claude-code overwrites the downgraded package.
Tested and confirmed working on claude-code@2.1.63, macOS 10.14.6, Node v20.20.0.
Suggested fixes
In order of preference:
- Graceful fallback: Catch the sharp loading failure and disable image features rather than crashing the entire process. This could be done by lazy-loading sharp in a child process or using
dlopenprobing before importing.
- Lower deployment target: Build (or request upstream to build) libvips with
MACOSX_DEPLOYMENT_TARGET=10.13. The@img/sharp-libvips-darwin-x64@1.0.0package already does this — the regression was introduced in later versions.
- Document minimum macOS version: If supporting pre-Catalina is not a goal, clearly document macOS 10.15 as the minimum requirement so users know before installing.
- Post-install check: Add a post-install script that detects the macOS version and warns (or auto-downgrades sharp) on pre-10.15 systems.
Steps to reproduce
- Install Claude Code on macOS Mojave 10.14.x:
npm i -g @anthropic-ai/claude-code - Start Claude Code:
claude - Drag any image file into the terminal (or trigger any image processing feature)
- Observe: process is killed with signal 9
Labels suggestion
bug, platform:macos, severity:crash
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗