Markdown file links with ~ (tilde) resolve relative to project root instead of home directory
Open 💬 0 comments Opened Jul 7, 2026 by ahhrealmonstr
Bug description
When Claude outputs a markdown file link using a ~ home-directory path (e.g. [file](~/Downloads/foo.pdf)), the IDE/UI resolves it as a path relative to the current project root rather than expanding ~ to the user's home directory.
Steps to reproduce
- Have Claude generate a file and save it to
~/Downloads/some-file.pdf - Claude responds with a markdown link:
[some-file.pdf](~/Downloads/some-file.pdf) - Click the link in the Claude Code UI
Expected behavior
~ expands to the user's home directory (/Users/<username>) and the file opens correctly.
Actual behavior
The path is resolved relative to the current working directory (the open project root), producing a path like /Users/bs/github/my-project/~/Downloads/some-file.pdf, which does not exist — resulting in a "Couldn't preview this file" error.
Workaround
Use the full absolute path in the markdown link instead of ~:[some-file.pdf](/Users/bs/Downloads/some-file.pdf)
Environment
- Platform: macOS (Darwin 25.6.0)
- Claude Code version: latest
- Triggered in: Claude Code desktop app / IDE extension file preview