[BUG] Auto-update breaks better-sqlite3 dependency causing sqlite DB access errors.
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 0.2.103 (Claude Code) (Started around 0.2.91)
- Operating System: macOS Sequoia 15.4.1
- Terminal: ghostty 1.0.1
Using Claude installed with npm globally and nodejs installed via homebrew.
$ node --version
v23.11.0
$ which node
/opt/homebrew/bin/node
$ ls -lah $(which claude)
lrwxr-xr-x@ 1 abraithwaite admin 52B May 6 19:36 /opt/homebrew/bin/claude -> ../lib/node_modules/@anthropic-ai/claude-code/cli.js
Bug Description
Whenever claude auto-update runs, I need to manually rebuild the better-sqlite3 dependency. Something is clearing it's build artifacts.
Steps to Reproduce
- Install Claude via npm globally, npm/nodejs installed via Homebrew.
- Wait for Claude to auto-update
- Restart claude after auto-update and the database will fail to open because the bindings were deleted.
Expected Behavior
I expect either the gyp bindings to not be deleted or for them to be rebuilt automatically.
Actual Behavior
The gyp bindings for better-sqlite3 are deleted and not rebuilt, causing claude to fail to open the sqlite database.
Workaround
cd /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3
npm run build-release
Additional Context
Build log for better-sqlite3: https://gist.github.com/abraithwaite/2547c53f3230f2ef28bc11b1835a4b09
Notably: I ran these commands right after claude auto-updated ☝. Note the files missing from the better-sqlite dependency tree.
The error text (notice "Database unavailable"). This state persists after restart until I rebuild the better-sqlite3 dependency.
╭─────────────────────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: /Users/abraithwaite/Projects/github.com/runreveal/runreveal │
│ │
│ Account: API │
╰─────────────────────────────────────────────────────────────────────╯
✔ Loaded project memory • /memory
⚠ Database unavailable: continue/resume features disabled • /doctor
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Try "fix lint errors" │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Press Ctrl-D again to exit
8 Comments
@abraithwaite sorry for the trouble. does it work if you do
npm install -g better-sqlite3@11.9.1The auto update just ran today, and broke again.
This time, I did not use the aforementioned workaround and instead installed the better-sqlite3 dependency globally (at version 11.9.1).
It is working now, and I'd expect will continue working since presumably the global dependency is being resolved first? Hopefully that helps!
I'd prefer if this would work with the internal dependencies for what it's worth. I'm sure you're working towards that, but having it rebuild on install seems like the best solution, particularly for versioned-managed node environments like we prefer to use. We frequently jump between node versions for various projects so the global better-sqlite3 dependency is less than ideal.
Edit: I take it back, something funky is going on with dependency resolution. The global dependency seems to work when the cwd is in claude-code's tree:
But not when outside of it:
Running the workaround again fixes it for when I'm outside the claude-code current working directory.
Fair enough @abraithwaite We are planning to remove this dependency because of the problems that it causes. We will be moving to file storage for conversations ASAP. Thanks for your patience and sorry for the churn.
No need to apologize. Thanks for not forgetting about the terminal zealots w/ Claude Code! Definitely the biggest change to my development since I started programming, and it's pretty damn good. :-)
@abraithwaite Solid catch. I ran into the exact same problem on Ubuntu 22.04 after an auto-update. The
better-sqlite3bindings got wiped and Claude couldn’t access the database until I manually rebuilt withnpm run build-releaseinside the module directory.In my case, Claude was installed globally via
npm, and this broke right after the update just like you described. So this definitely isn’t limited to macOS/Homebrew environments, looks like a broader issue with how the update handles native dependencies.Thanks for sharing the workaround. Looking forward to the file-based storage update — that sounds like a smart long-term fix.
File based storage shipped with v0.2.107 today. We'll be removing the dependency next week
The sqlite dependency was removed in v0.2.113 which shipped last night. Happy Clauding!
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.