fix(agents): WSL "Open session" starts the agent through a login shell
- `wsl.exe -e claude` execs without a login shell, so ~/.local/bin is not on PATH:
"execvpe(claude) failed: No such file or directory". Runs already used `sh -lc`.
- Defaults now `wsl.exe --cd {cwd} -e sh -lc "exec claude --resume {session_id}"` (same for copilot).
- Saved settings with the exact old default are migrated on load; custom commands stay.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -493,7 +493,16 @@ mod tests {
493
493
assert_eq!(invocation.program, "wt.exe");
494
494
assert_eq!(
495
495
invocation.args,
496
["wsl.exe", "--cd", "~", "-e", "claude", "--resume", "sid-4"].map(String::from)
496
[
497
"wsl.exe",
498
"--cd",
499
"~",
500
"-e",
501
"sh",
502
"-lc",
503
"exec claude --resume sid-4"
504
]
505
.map(String::from)
497
506
);
498
507
}
499
508
@@ -493,7 +493,16 @@ mod tests {493
assert_eq!(invocation.program, "wt.exe");493
assert_eq!(invocation.program, "wt.exe");494
assert_eq!(494
assert_eq!(495
invocation.args,495
invocation.args,496
["wsl.exe", "--cd", "~", "-e", "claude", "--resume", "sid-4"].map(String::from)496
[497
"wsl.exe",498
"--cd",499
"~",500
"-e",501
"sh",502
"-lc",503
"exec claude --resume sid-4"504
]505
.map(String::from)497
);506
);498
}507
}499
508
@@ -3,6 +3,14 @@ use serde::{Deserialize, Serialize};
3
3
const CLAUDE_COMMAND: &str =
4
4
"claude -p --output-format stream-json --verbose --session-id {session_id}";
5
5
const COPILOT_COMMAND: &str = "copilot -p {prompt} --output-format json --session-id {session_id}";
6
pub(crate) const LEGACY_CLAUDE_WSL_OPEN_SESSION: &str =
7
"wt.exe wsl.exe --cd {cwd} -e claude --resume {session_id}";
8
pub(crate) const LEGACY_COPILOT_WSL_OPEN_SESSION: &str =
9
"wt.exe wsl.exe --cd {cwd} -e copilot --resume {session_id}";
10
const CLAUDE_WSL_OPEN_SESSION: &str =
11
"wt.exe wsl.exe --cd {cwd} -e sh -lc \"exec claude --resume {session_id}\"";
12
const COPILOT_WSL_OPEN_SESSION: &str =
13
"wt.exe wsl.exe --cd {cwd} -e sh -lc \"exec copilot --resume {session_id}\"";
6
14
7
15
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
8
16
pub enum Environment {
@@ -34,6 +42,15 @@ pub struct AgentProfile {
34
42
}
35
43
36
44
impl AgentProfile {
45
pub(crate) fn migrate_open_session_command(&mut self) {
46
let replacement = match self.open_session_command.as_str() {
47
LEGACY_CLAUDE_WSL_OPEN_SESSION => CLAUDE_WSL_OPEN_SESSION,
48
LEGACY_COPILOT_WSL_OPEN_SESSION => COPILOT_WSL_OPEN_SESSION,
49
_ => return,
50
};
51
self.open_session_command = replacement.to_string();
52
}
53
37
54
pub fn claude_wsl() -> Self {
38
55
Self {
39
56
id: "claude".to_string(),
@@ -41,8 +58,7 @@ impl AgentProfile {
41
58
environment: Environment::Wsl { distro: None },
42
59
command: CLAUDE_COMMAND.to_string(),
43
60
output: OutputFormat::ClaudeStreamJson,
44
open_session_command: "wt.exe wsl.exe --cd {cwd} -e claude --resume {session_id}"
45
.to_string(),
61
open_session_command: CLAUDE_WSL_OPEN_SESSION.to_string(),
46
62
mcp_config_flag: "--mcp-config".to_string(),
47
63
}
48
64
}
@@ -66,8 +82,7 @@ impl AgentProfile {
66
82
environment: Environment::Wsl { distro: None },
67
83
command: COPILOT_COMMAND.to_string(),
68
84
output: OutputFormat::CopilotJsonl,
69
open_session_command: "wt.exe wsl.exe --cd {cwd} -e copilot --resume {session_id}"
70
.to_string(),
85
open_session_command: COPILOT_WSL_OPEN_SESSION.to_string(),
71
86
mcp_config_flag: "--additional-mcp-config".to_string(),
72
87
}
73
88
}
@@ -3,6 +3,14 @@ use serde::{Deserialize, Serialize};3
const CLAUDE_COMMAND: &str =3
const CLAUDE_COMMAND: &str =4
"claude -p --output-format stream-json --verbose --session-id {session_id}";4
"claude -p --output-format stream-json --verbose --session-id {session_id}";5
const COPILOT_COMMAND: &str = "copilot -p {prompt} --output-format json --session-id {session_id}";5
const COPILOT_COMMAND: &str = "copilot -p {prompt} --output-format json --session-id {session_id}";6
pub(crate) const LEGACY_CLAUDE_WSL_OPEN_SESSION: &str =7
"wt.exe wsl.exe --cd {cwd} -e claude --resume {session_id}";8
pub(crate) const LEGACY_COPILOT_WSL_OPEN_SESSION: &str =9
"wt.exe wsl.exe --cd {cwd} -e copilot --resume {session_id}";10
const CLAUDE_WSL_OPEN_SESSION: &str =11
"wt.exe wsl.exe --cd {cwd} -e sh -lc \"exec claude --resume {session_id}\"";12
const COPILOT_WSL_OPEN_SESSION: &str =13
"wt.exe wsl.exe --cd {cwd} -e sh -lc \"exec copilot --resume {session_id}\"";6
14
7
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]15
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]8
pub enum Environment {16
pub enum Environment {@@ -34,6 +42,15 @@ pub struct AgentProfile {34
}42
}35
43
36
impl AgentProfile {44
impl AgentProfile {45
pub(crate) fn migrate_open_session_command(&mut self) {46
let replacement = match self.open_session_command.as_str() {47
LEGACY_CLAUDE_WSL_OPEN_SESSION => CLAUDE_WSL_OPEN_SESSION,48
LEGACY_COPILOT_WSL_OPEN_SESSION => COPILOT_WSL_OPEN_SESSION,49
_ => return,50
};51
self.open_session_command = replacement.to_string();52
}53
37
pub fn claude_wsl() -> Self {54
pub fn claude_wsl() -> Self {38
Self {55
Self {39
id: "claude".to_string(),56
id: "claude".to_string(),@@ -41,8 +58,7 @@ impl AgentProfile {41
environment: Environment::Wsl { distro: None },58
environment: Environment::Wsl { distro: None },42
command: CLAUDE_COMMAND.to_string(),59
command: CLAUDE_COMMAND.to_string(),43
output: OutputFormat::ClaudeStreamJson,60
output: OutputFormat::ClaudeStreamJson,44
open_session_command: "wt.exe wsl.exe --cd {cwd} -e claude --resume {session_id}"61
open_session_command: CLAUDE_WSL_OPEN_SESSION.to_string(),45
.to_string(),46
mcp_config_flag: "--mcp-config".to_string(),62
mcp_config_flag: "--mcp-config".to_string(),47
}63
}48
}64
}@@ -66,8 +82,7 @@ impl AgentProfile {66
environment: Environment::Wsl { distro: None },82
environment: Environment::Wsl { distro: None },67
command: COPILOT_COMMAND.to_string(),83
command: COPILOT_COMMAND.to_string(),68
output: OutputFormat::CopilotJsonl,84
output: OutputFormat::CopilotJsonl,69
open_session_command: "wt.exe wsl.exe --cd {cwd} -e copilot --resume {session_id}"85
open_session_command: COPILOT_WSL_OPEN_SESSION.to_string(),70
.to_string(),71
mcp_config_flag: "--additional-mcp-config".to_string(),86
mcp_config_flag: "--additional-mcp-config".to_string(),72
}87
}73
}88
}@@ -57,7 +57,11 @@ impl AgentSettings {
57
57
}
58
58
59
59
pub fn from_json(json: &str) -> Result<Self, serde_json::Error> {
60
serde_json::from_str(json)
60
let mut settings: Self = serde_json::from_str(json)?;
61
for agent in &mut settings.agents {
62
agent.migrate_open_session_command();
63
}
64
Ok(settings)
61
65
}
62
66
63
67
pub fn validate(&self) -> Vec<SettingsProblem> {
@@ -103,6 +107,28 @@ mod tests {
103
107
assert!(settings.validate().is_empty());
104
108
}
105
109
110
#[test]
111
fn from_json_migrates_legacy_wsl_open_session_commands_only() {
112
let legacy = AgentSettings::from_json(&format!(
113
r#"{{"agents":[{{"id":"claude","open_session_command":"{}"}},{{"id":"copilot","open_session_command":"{}"}},{{"id":"mine","open_session_command":"wt.exe wsl.exe -e claude --resume {{session_id}}"}}]}}"#,
114
crate::profile::LEGACY_CLAUDE_WSL_OPEN_SESSION,
115
crate::profile::LEGACY_COPILOT_WSL_OPEN_SESSION,
116
))
117
.unwrap();
118
assert_eq!(
119
legacy.agents[0].open_session_command,
120
AgentProfile::claude_wsl().open_session_command
121
);
122
assert_eq!(
123
legacy.agents[1].open_session_command,
124
AgentProfile::copilot_wsl().open_session_command
125
);
126
assert_eq!(
127
legacy.agents[2].open_session_command,
128
"wt.exe wsl.exe -e claude --resume {session_id}"
129
);
130
}
131
106
132
#[test]
107
133
fn empty_object_loads_defaults() {
108
134
assert_eq!(
@@ -57,7 +57,11 @@ impl AgentSettings {57
}57
}58
58
59
pub fn from_json(json: &str) -> Result<Self, serde_json::Error> {59
pub fn from_json(json: &str) -> Result<Self, serde_json::Error> {60
serde_json::from_str(json)60
let mut settings: Self = serde_json::from_str(json)?;61
for agent in &mut settings.agents {62
agent.migrate_open_session_command();63
}64
Ok(settings)61
}65
}62
66
63
pub fn validate(&self) -> Vec<SettingsProblem> {67
pub fn validate(&self) -> Vec<SettingsProblem> {@@ -103,6 +107,28 @@ mod tests {103
assert!(settings.validate().is_empty());107
assert!(settings.validate().is_empty());104
}108
}105
109
110
#[test]111
fn from_json_migrates_legacy_wsl_open_session_commands_only() {112
let legacy = AgentSettings::from_json(&format!(113
r#"{{"agents":[{{"id":"claude","open_session_command":"{}"}},{{"id":"copilot","open_session_command":"{}"}},{{"id":"mine","open_session_command":"wt.exe wsl.exe -e claude --resume {{session_id}}"}}]}}"#,114
crate::profile::LEGACY_CLAUDE_WSL_OPEN_SESSION,115
crate::profile::LEGACY_COPILOT_WSL_OPEN_SESSION,116
))117
.unwrap();118
assert_eq!(119
legacy.agents[0].open_session_command,120
AgentProfile::claude_wsl().open_session_command121
);122
assert_eq!(123
legacy.agents[1].open_session_command,124
AgentProfile::copilot_wsl().open_session_command125
);126
assert_eq!(127
legacy.agents[2].open_session_command,128
"wt.exe wsl.exe -e claude --resume {session_id}"129
);130
}131
106
#[test]132
#[test]107
fn empty_object_loads_defaults() {133
fn empty_object_loads_defaults() {108
assert_eq!(134
assert_eq!(