[BUG] claude code crashes with 'Path contains null bytes' error with CLAUDE.md reference to image file

Resolved 💬 7 comments Opened Sep 1, 2025 by grempe Closed Jan 22, 2026

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ X] Other: claude code
  • Claude CLI version: 1.0.98
  • Operating System: macOS
  • Terminal: Warp

Bug Description

Using latest version of Claude Code I found an issue that was causing claude to crash on start in the terminal every time. I narrowed the issue down to something that I had not done before. I had a logo image that I wanted to use as the starter seed for prompts to create a simple application, using the logo to help inform the style and colors. This worked fine, until I restarted claude at which point it wouild always crash. It took me a long time to narrow it down to the fact that in my CLAUDE.md file I made reference with an '@' to this file as part of the prompt. Repeatably, if I have this reference in CLAUDE.md claude will crash on startup. However, if I remove the reference (or even change it to a filename of a non-existant file by changing its name), claude starts fine.

Example:

# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

If you leave this reference here to the logo file found at @hooked-logo.png in this dir claude will crash. If you remove the reference to the png file, or change its name to a non-existant file, claude will start fine. See the output in CRASH.txt

Note : I also downloaded another rather random .png image and made a similar reference to it in CLAUDE.md and it does NOT cause a crash. So it might be something about my exact image contents that causes this (see the reference in the crash to 'Path contains null bytes'.

Steps to Reproduce

  1. Add reference to @hooked-logo.png in CLAUDE.md
  2. start claude at command line
  3. claude crashes

Use the sample repo to test failure which fails every time for me. This includes the exact image that was causing my issue.

https://github.com/grempe/claude-crash-test

Expected Behavior

Claude should fail gracefully, or just work with any image referenced in CLAUDE.md.

Actual Behavior

Claude crashes

Additional Context

Bug test repo:

https://github.com/grempe/claude-crash-test

<img width="1024" height="1024" alt="Image" src="https://github.com/user-attachments/assets/16f67ee4-912c-45cc-a490-2724289463c1" />

❯ claude
file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:712
`);if(this.cache.set(Z,{content:I,encoding:Y,mtime:Q.mtimeMs}),this.cache.size>this.maxCacheSize){let W=this.cache.keys().next().value;if(W)this.cache.delete(W)}return{content:I,encoding:Y}}clear(){this.cache.clear()}invalidate(A){this.cache.delete(A)}getStats(){return{size:this.cache.size,entries:Array.from(this.cache.keys())}}}var nJA=new iJA;import{join as OVA,posix as Dh,resolve as yI9,sep as RVA}from"path";import{homedir as aJA}from"os";import{isAbsolute as JZ9,join as XZ9,resolve as FZ9,normalize as sJA,dirname as VZ9}from"path";function P7(A,B){let Q=B??BA()??M1().cwd();if(typeof A!=="string")throw new TypeError(`Path must be a string, received ${typeof A}`);if(typeof Q!=="string")throw new TypeError(`Base directory must be a string, received ${typeof Q}`);if(A.includes("\x00")||Q.includes("\x00"))throw new Error("Path contains null bytes");let Z=A.trim();if(!Z)return sJA(Q);if(Z==="~")return aJA();if(Z.startsWith("~/"))return XZ9(aJA(),Z.slice(2));if(JZ9(Z))return sJA(Z);return FZ9(Q,Z)}function Oy(A){let B=P7(A);try{if(M1().statSync(B).isDirectory())return B}catch{}return VZ9(B)}import{execSync as kr1}from"node:child_process";import*as YXA from"node:path/win32";var IXA=Q1(TK(),1);function yr1(A){try{return kr1(`dir "${A}"`,{stdio:"pipe"}),!0}catch{return!1}}function LZ9(A){if(A==="git"){let B=["C:\\Program Files\\Git\\cmd\\git.exe","C:\\Program Files (x86)\\Git\\cmd\\git.exe"];for(let Q of B)if(yr1(Q))return Q}try{return kr1(`where.exe ${A}`,{stdio:"pipe",encoding:"utf8"}).trim().split(`\r
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ^

Error: Path contains null bytes
    at P7 (file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:712:823)
    at ni (file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:746:3045)
    at zPB (file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2237:1456)
    at Qd (file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2237:2523)
    at Qd (file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2237:2549)
    at file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2237:2892
    at Q (file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:671:13288)
    at CPB (file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2237:3128)
    at file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2439:165
    at Q (file:///Users/glenn/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:671:13288)

Node.js v24.1.0

View original on GitHub ↗

This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗