anthropics / anthropics/claude-code

[BUG] sshConfigs startDirectory is accepted by the schema but ignored when a session starts

オープン
#91,171 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:desktop bug has repro platform:macos
主要言語
Python
スター
145k
フォーク
23.1k
PR マージ指標
PR 指標を取得中

説明

### Preflight Checklist

- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) 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?

An SSH connection defined in `~/.claude/settings.json` with `startDirectory` connects correctly, but the session opens in the **remote user's home directory** instead of the directory I specified.

Because session history is keyed on the working directory, the session also starts with an **empty history**. A machine I had been working on from the CLI opens in the desktop app showing none of my conversations. The transcripts are intact on the host, just stored under the key for the other path, but it reads as data loss.

The field is schema-validated (an invalid type is rejected), so it is accepted and then discarded rather than ignored as unknown.

### What Should Happen?

The session opens in the directory given by `startDirectory`, as documented:

> Default working directory on the remote host. Supports tilde expansion (e.g. ~/projects). If not specified, defaults to the remote user home directory.

I did specify it, so the default should not apply.

### Error Messages/Logs

```shell

```

### Steps to Reproduce

1. Add an SSH connection to `~/.claude/settings.json`:

```json
{
"sshConfigs": [
{
"id": "team.project-a",
"name": "Project A",
"sshHost": "project-a",
"startDirectory": "/opt/src/project-a"
}
]
}
```

2. Restart Claude Desktop and open the Code tab.
3. Pick "Project A" from the environment dropdown. It connects.
4. Ask Claude what the working directory is, or run `pwd`.
5. It reports the remote user's home directory, not `/opt/src/project-a`.
6. On the remote host, `ls ~/.claude/projects/` shows a store keyed on the home directory rather than on the configured one, which is why the history looks empty.

### Claude Model

_No response_

### Is this a regression?

I don't know

### Last Working Version

_No response_

### Claude Code Version

2.1.56 (Claude Code); Claude Desktop 1.40609.0

### Platform

Anthropic API

### Operating System

macOS

### Terminal/Shell

Terminal.app (macOS)

### Additional Information

**Why this matters beyond one setting**

For anyone managing a fleet of remote development machines, every connection needs a manual folder step before it is usable, per machine and per developer. The published `startDirectory` is the only mechanism for that, so there is currently no way to hand someone a ready-to-use connection.

**Possibly useful**

Connections supplied by at least one built-in integration do open at a working directory, so the session model appears to carry one already; it looks like the settings path simply does not pass the value through.

The documented workaround, `claude ssh [dir]`, does not currently run either. Filed separately.

**Searched first:** #83561 also involves `sshConfigs` but is a different problem (the SSH environment never appearing in third-party API mode). I found no existing report of `startDirectory` being ignored.

Desktop app version: 1.40609.0. Also reproduced on 1.37937.3.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

The report identifies ~/.claude/settings.json and the sshConfigs.startDirectory setting, but no implementation file or test. Start by tracing how this value reaches SSH session startup; verify completion by reproducing the connection and confirming that the session opens in the configured remote directory and uses the corresponding history.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。