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: Windows .exe compatibility for VSCode #12761

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

cdamus
Copy link
Contributor

@cdamus cdamus commented Jul 26, 2023

What it does

On Windows platform, support implicit file '.exe' extension on the shell command in terminal profiles as in VS Code.

VS Code allows a terminal profile to omit the '.exe' extension of the executable file and will find and run it anyways. So this PR enhances the TerminalProcess initialization, in the case that the program launch fails by reason of not being found and the host platform is Windows and the command did not end with '.exe', to try again with '.exe' appended to the program.

Fixes #12734

How to test

Per the description of #12734:

  1. Clone the OP's referenced sample repository
  2. Check out the terminal branch. This provides a myext VS Code extension that you can link into your plugins/ directory to obtain a "Profile from my extension" terminal profile. This is configured simply with 'cmd' as the command to run, not 'cmd.exe'.
  3. Launch Theia and start a new terminal using the "Profile from my extension" profile in the Terminal menu.
  4. See that the terminal starts (you may observe other unrelated issues as described in other bugs filed by the OP).

Review checklist

Reminder for reviewers

@cdamus
Copy link
Contributor Author

cdamus commented Jul 26, 2023

Yeah, I can see why the test failed and what I did wrong. Easy to fix.

@cdamus
Copy link
Contributor Author

cdamus commented Jul 26, 2023

Commit e0e2b2e fixes the problem that broke the test and adds a new test case for this PR's Windows-specific behaviour.

@jfaltermeier jfaltermeier self-requested a review July 27, 2023 13:50
Copy link
Contributor

@jfaltermeier jfaltermeier left a comment

Choose a reason for hiding this comment

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

LGTM. I've tested with the instructions from the ticket.
Besides the refactoring with the introduction of the createPseudoTerminal method, the only code change is the addition of the if (isWindows && command && !command.toLowerCase().endsWith('.exe')) clause, which looks good to me.

if (message.startsWith('File not found: ') || message.endsWith(NodePtyErrors.ENOENT)) {
if (isWindows && command && !command.toLowerCase().endsWith('.exe')) {
const commandExe = command + '.exe';
this.logger.warn(`Trying terminal command '${commandExe}' because '${command}' was not found.`);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion here, but imo this could be an info message as well.
I guess it depends on whether we see this more as a feature or more as a fallback for a misconfiguration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, that's a good point. I might rather lean to 'debug' as this is supposed to be unsurprising and totally supported behaviour, but should still be recorded in case some flow doesn't happen as expect. For example, in the — decidedly inadvisable — case where a .exe file exists but the developer doesn't want it to be used in the case that the unsuffixed file doesn't exist?

Copy link
Contributor Author

@cdamus cdamus Jul 27, 2023

Choose a reason for hiding this comment

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

Changed in commit dcdd3f1 to debug level.

@cdamus cdamus force-pushed the issue/12734 branch 2 times, most recently from b5d02c6 to 348dd1e Compare July 27, 2023 19:01
@cdamus
Copy link
Contributor Author

cdamus commented Jul 27, 2023

I should mention also that this PR fixes deprecation warnings in the listener API usage of the IPty terminal object. Good opportunity while the file was being changed anyways and the terminal set-up factored out into a helper method.

Support implicit '.exe' extension on the shell
command in terminal profiles as in VS Code.

Fixes eclipse-theia#12734

Signed-off-by: Christian W. Damus <cdamus.ext@eclipsesource.com>
@vince-fugnitto vince-fugnitto added terminal issues related to the terminal OS/Windows issues related to the Windows OS labels Aug 3, 2023
@jfaltermeier jfaltermeier merged commit 2747ee5 into eclipse-theia:master Aug 7, 2023
6 checks passed
@cdamus cdamus deleted the issue/12734 branch August 7, 2023 14:08
@vince-fugnitto vince-fugnitto added this to the 1.41.0 milestone Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS/Windows issues related to the Windows OS terminal issues related to the terminal
Projects
Archived in project
3 participants