Skip to content

Commit efef68f

Browse files
authored
Use login shell to start aish in sidecar pane to inherit proper PATH (#403)
On macOS, when using the sidecar experience, `aish` cannot start local MCP servers and the `Azure` agent cannot get the access token from Az CLI. This is due to the PATH environment variable not properly setup when iTerm2 starts `"aish --Channel ..."` in the new pane. iTerm2 uses `exec` to run the `aish` command, which directly execute the program without setting up the environment variables properly. Because of that, the `az` and `pwsh` commands cannot be found when retrieving access token, and the MCP server commands cannot be found too, which caused local MCP servers to always fail to start. The fix is to wrap it with `zsh` by `/bin/zsh -l -c "<aish-path> --channel <channel-string>"`. In this way, `zsh` will set up the environment properly, which will then be inherited by `aish`.
1 parent a1125f6 commit efef68f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

shell/AIShell.Integration/InitAndCleanup.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace AIShell.Integration;
77

88
public class InitAndCleanup : IModuleAssemblyInitializer, IModuleAssemblyCleanup
99
{
10-
private const int ScriptVersion = 1;
10+
private const int ScriptVersion = 2;
1111
private const string ScriptFileTemplate = "aish_split_pane_v{0}.py";
1212
private const string SplitPanePythonCode = """
1313
import iterm2
@@ -31,7 +31,8 @@ await app.async_activate()
3131
3232
change = iterm2.LocalWriteOnlyProfile()
3333
change.set_use_custom_command('Yes')
34-
change.set_command(f'{app_path} --channel {channel}')
34+
# Use login shell to inherit proper PATH and environment
35+
change.set_command(f'/bin/zsh -l -c "{app_path} --channel {channel}"')
3536
3637
# Split pane vertically
3738
split_pane = await current_pane.async_split_pane(vertical=True, profile_customizations=change)

0 commit comments

Comments
 (0)