Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal Preview returns ERROR_FILE_NOT_FOUND when launching relative path #15487

Closed
ChrisKnue-MSFT opened this issue May 30, 2023 · 5 comments
Closed
Assignees
Labels
In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree.

Comments

@ChrisKnue-MSFT
Copy link

Windows Terminal version

1.18.1421.0

Windows build number

10.0.22631.0

Other Software

No response

Steps to reproduce

Attempt to launch a terminal from command line with a relative path for a file to launch. (ex: "wt .\test.ps1")

Expected Behavior

In 1.16.10262.0 this would launch the file

Actual Behavior

[error 2147942402 (0x80070002) when launching .\test.ps1]
is printed in the console.

@ChrisKnue-MSFT ChrisKnue-MSFT added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 30, 2023
@zadjii-msft
Copy link
Member

Undoubtably, I broke this in #15280. Or at least, forgot about this scenario 🤦

@zadjii-msft zadjii-msft added Product-Terminal The new Windows Terminal. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 31, 2023
@zadjii-msft zadjii-msft added this to the Terminal v1.19 milestone May 31, 2023
@zadjii-msft zadjii-msft added the Severity-Blocking We won't ship a release like this! No-siree. label May 31, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements labels May 31, 2023
@zadjii-msft
Copy link
Member

Hmmmmmm. This is tricky. So we've got a virtual CWD now, and our real CWD is system32.

As an example, cd to d:\dev\tmp, and try to launch foo.exe. In this scenario:

  • when we get to _evaluatePathForCwd in TerminalPage::_CreateConnectionFromSettings, we evaluate (_WindowProperties.VirtualWorkingDirectory(), path) == ("d:\dev\tmp", "") -> `"d:\dev\tmp"'. That's right.
  • But the problem is that we don't CreateProcess then. We CreateProcess in ConptyConnection::Start, which straight up isn't till the TermControl is initialized with XAML.
  • At that point, we CreateProcess("foo.exe",..... "d:\dev\tmp"). But that gives a ERROR_FILE_NOT_FOUND, cause there's no foo.exe in system32.

I wonder if there's a trivial flag to try to load the process from the startingDirectory. Or like, as a fail-safe, fall back to trying the startingDirectory, like, by appending the commandline to that? idk. needs more brainstorming.

@zadjii-msft
Copy link
Member

zadjii-msft commented May 31, 2023

But it's not just {{startingDirectory}}/{{commandline}}. It's more like the search path has to be {{terminal's vCWD when that connection was created}}/{{commandline}}.

Ew this is hard. Cause we don't know the application that we're calling CreateProcess on. We're just passing the whole commandline, and letting CreateProcess figure it out. We could theoretically, temporarily attempt to have the Terminal cd into the vCwd, and try again. That also feels hacky but hey, that's kinda this whole project

@ChrisKnue-MSFT
Copy link
Author

@zadjii-msft We were trying some work arounds (absolute path) and it seems like environment variables are not being passed to the child wt process either. Is there already a bug about that?

@zadjii-msft
Copy link
Member

Talked this over internally - The fix (as in #16028) for this bug is.... unbelievably gross, and probably even incorrect. This is just gonna have to remain a breaking change post-1.18. The workaround being to always pass absolute paths to the wt commandline (which will work on old versions as well as new).

@zadjii-msft zadjii-msft closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants