Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/sshx/src/terminal/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use tracing::instrument;
/// for Powershell to launch. This is why I don't typically use Windows!
pub async fn get_default_shell() -> String {
for shell in [
"C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"C:\\Program Files\\Git\\bin\\bash.exe",
"C:\\Windows\\System32\\cmd.exe",
] {
Expand Down Expand Up @@ -46,6 +47,12 @@ impl Terminal {
pub async fn new(shell: &str) -> Result<Terminal> {
let mut command = Command::new(shell);

// Inherit all environment variables from the current process.
// This ensures PATH and other important variables are preserved.
for (key, value) in std::env::vars() {
command.env(key, value);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try with removing this line? It shouldn't be necessary, child processes inherit from their parent process by default https://doc.rust-lang.org/beta/std/process/struct.Command.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I test, without this, $PATH does not have claude and others commands.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's very strange. I don't think we can merge this without understanding why PATH is being set strangely though, it may cause other edge cases to surface. Perhaps PowerShell is overriding your PATH on startup?

}

// Set terminal environment variables appropriately.
command.env("TERM", "xterm-256color");
command.env("COLORTERM", "truecolor");
Expand Down