[BUG] Auto-update breaks better-sqlite3 dependency causing sqlite DB access errors.

Status Fixed / completed
Maintainer reply ✓ Yes — wolffiex
Activity 8 comments · opened May 7, 2025 · closed May 14, 2025
💡 Likely answer: A maintainer (wolffiex, collaborator) responded on this thread — see the highlighted reply below.

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

  1. Install Claude via npm globally, npm/nodejs installed via Homebrew.
  2. Wait for Claude to auto-update
  3. 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

View original on GitHub ↗

8 Comments

wolffiex collaborator · 1 year ago

@abraithwaite sorry for the trouble. does it work if you do
npm install -g better-sqlite3@11.9.1

abraithwaite · 1 year ago

The 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:

abraithwaite at gibson in /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3 (master)
15:04:19 $ claude
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview!                                                   │
│                                                                                              │
│   /help for help, /status for your current setup                                             │
│                                                                                              │
│   cwd: /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3  │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯

 Tips for getting started:

 1. Run /init to create a CLAUDE.md file with instructions for Claude
 2. Use Claude to help with file analysis, editing, bash commands and git
 3. Be as specific as you would with another engineer for the best results

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Try "edit cmd/upgrade.rb to..."                                                                                                                           │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  Press Ctrl-D again to exit



Total cost:            $0.0000
Total duration (API):  0s
Total duration (wall): 3.5s
Total code changes:    0 lines added, 0 lines removed
Tokens:                0 base input, 0 cache write, 0 cache read, 0 base output

But not when outside of it:

abraithwaite at gibson in ~/Projects/github.com/runreveal/runreveal (alan/oauth-server●)
15:12:20 $ claude
╭─────────────────────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview!                          │
│                                                                     │
│   /help for help, /status for your current setup                    │
│                                                                     │
│   cwd: /Users/abraithwaite/Projects/github.com/runreveal/runreveal  │
╰─────────────────────────────────────────────────────────────────────╯

 ⚠ Database unavailable: continue/resume features disabled • /doctor

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Try "how does server.go work?"                                                                                                                            │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  Press Ctrl-D again to exit



Total cost:            $0.0000
Total duration (API):  0s
Total duration (wall): 1.9s
Total code changes:    0 lines added, 0 lines removed
Tokens:                0 base input, 0 cache write, 0 cache read, 0 base output

Running the workaround again fixes it for when I'm outside the claude-code current working directory.

wolffiex collaborator · 1 year ago

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.

abraithwaite · 1 year ago

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. :-)

PaulyBearCoding · 1 year ago

@abraithwaite Solid catch. I ran into the exact same problem on Ubuntu 22.04 after an auto-update. The better-sqlite3 bindings got wiped and Claude couldn’t access the database until I manually rebuilt with npm run build-release inside 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.

wolffiex collaborator · 1 year ago

File based storage shipped with v0.2.107 today. We'll be removing the dependency next week

wolffiex collaborator · 1 year ago

The sqlite dependency was removed in v0.2.113 which shipped last night. Happy Clauding!

github-actions[bot] · 1 year ago

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.