Skip to content

Conversation

marcocondrache
Copy link
Contributor

@marcocondrache marcocondrache commented Oct 7, 2025

Closes #39614

The ShellKind struct is built on Windows' side, meaning that when connecting to remotes, we fall back to PowerShell construction, even if the shell program we are spawning is a unix program.

This broke tasks creation since we are using the shell kind to construct args:

if let Some(command) = &mut command

In normal terminals this only affected activation scripts (only place where shell kind is used)

I don't have a Windows machine to test it, so I would appreciate any help with testing!

Release Notes:

  • Fixed an issue where tasks could not be executed in Windows WSL

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 7, 2025
let program = program.as_ref();
let Some(program) = program.file_stem().and_then(|s| s.to_str()) else {
return if cfg!(windows) {
return if cfg!(windows) && program.to_string_lossy().contains("\\") {
Copy link
Member

@kubkon kubkon Oct 7, 2025

Choose a reason for hiding this comment

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

I was wondering, should we even bother with early return here? Let's suppose that program.file_stem() == None. Then, we could unwrap into program itself and do matching that follows. Something like this:

let program = program.file_stem().unwrap_or_else(|| program.as_os_str()).to_str();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kubkon, that's a good idea. Conversion to a string doesn't work without passing through an option or result, so in this case, only to_string_lossy would work. I don't think this is a problem since we are only retrieving the filename, which would simply fallback

ShellKind::Posix
} else {
if cfg!(windows) {
if cfg!(windows) && program.contains("\\") {
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why you think this check is valid? What does the program path look like when executing a command on the remote server while host is WIndows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let shell_kind = ShellKind::new(&shell);

The input of the shell kind struct it's a shell program, that on remote clients like WSL are unix programs.

Take as example the command of the original issue:

/usr/bin/zsh -C 'pwd'

If our host is Windows then we should fallback to PowerShell construction only if the program it's a windows path style

Copy link
Member

Choose a reason for hiding this comment

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

I think we can do this in a more reliable way by passing an is_windows: bool argument, which we can get off the project in callers by project.path_style(cx).is_windows(), or client.path_style().is_windows() if we have a RemoteClient in the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cole-miller, that's true. I've added the argument and updated ShellBuilder, along with all its usages, to pass this argument. Please double-check the changes!

Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Signed-off-by: Marco Mihai Condrache <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tasks not running on WSL (wrong flag passed to zsh)
3 participants