[BUG] Bash input cwd is literal "~" instead of expanded $HOME on remote Linux host

Resolved 💬 1 comment Opened May 27, 2026 by wallfacer005-vip Closed Jun 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Environment

  • Client: Claude Code Mac desktop
  • Remote host: Linux (Amazon Linux 2, kernel 4.14)
  • Remote user: ec2-user, $HOME=/home/ec2-user
  • Connection: SSH to EC2

Description

When typing bash commands via the bash-input feature (e.g. ls, whoami),
every command immediately fails with:
Working directory "~" does not exist

What Should Happen?

The bash-input tool is being invoked with the literal string ~ as its
working directory, instead of the expanded path /home/ec2-user. The
remote shell never gets a chance to expand ~ because the cwd check
happens before the command runs.

Reproduction

  1. Launch Claude Code Mac desktop, connect to a remote Linux host
  2. In the chat, use bash-input mode to run any command, e.g. ls
  3. Observe the error

Expected

The cwd should be either:

  • Expanded on the client side before sending (~/Users/<me> is wrong

here anyway since the agent runs remotely), OR

  • Sent as the actual remote $HOME path resolved at session start

Actual

Literal ~ is passed, which is not a valid directory path on the remote
filesystem.

Workaround

The agent's own Bash tool works correctly (its cwd is /home/ec2-user), so
asking Claude to run commands in chat works. Only bash-input is broken.

Additional context

  • ~/.claude.json has no projects or cwd field on the remote host
  • The agent's environment reports "Primary working directory: /home/ec2-user"

correctly, so the issue is specifically in how bash-input resolves cwd

Error Messages/Logs

Steps to Reproduce

~

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude 1.9255.2 (1dc8f7) 2026-05-27T01:57:20.000Z

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗