-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
[WIP] Use WSL PHP for validation #25576
Conversation
Same issue happens if I directly invoke bash with |
Also, if I directly run |
Hey @codeguy We'll look at it from the console/WSL side. |
@khouzam I've gotten stdout from bash to work. However, I'm now seeing my Linux paths being auto-converted back to C:\ style path... not sure if Node is doing this, or Bash, or what. Doesn't happen when I invoke directly in console. It is happening in Node when compiled app is run via Electron. See screen cap. |
I've hooked up config settings. You can use these to validate via WSL shell:
I still need to complete these tasks:
|
@codeguy thanks a lot for looking into this. A couple of first remarks: we should implement the feature in a way that it can be used to execute php in a shell as well. So the path conversion to WSL should only happen in Windows and only if the shell is bash.exe. To make it consistent with other settings we have for tasks.json I would prefer something like this: {
"php.validate.executablePath": "/usr/bin/php",
"php.validate.runInShell": {
"executable": "C:\\Windows\\sysnative\\bash.exe",
"shellArgs": [ "-c" ]
}
} we should also allow to use a boolean for {
"php.validate.executablePath": "/usr/bin/php",
"php.validate.runInShell": true
} |
@dbaeumer Thanks for the feedback. Most recent commit standardizes settings. You can now use:
This will default to
I also attempted to declare the possible configuration settings in |
@dbaeumer I'm going to remove the last remaining |
@codeguy more feedback:
And thanks again for looking into this. |
I keep forgetting this is cross-platform :) Will take care of these issues tonight. |
Latest commits include the following changes:
|
@@ -147,6 +150,11 @@ export default class PHPValidationProvider { | |||
let shellSettings = section.get<any>('validate.runInShell'); | |||
if (typeof(shellSettings) === 'boolean') { | |||
this.runInShell = shellSettings; | |||
if (this.platform.toLowerCase() === 'win32') { | |||
this.shellExecutable = 'C:\\Windows\\sysnative\\bash.exe'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can't assume that a user wants the bash if runInShell is set to true. I would expect that the user wants to use what is defined in ComSpec under Windows.
And then we need to set the shellArgs accordingly as well since -c will not work with cmd.exe nor with powershell.exe. For cmd.exe this is /C and for PowerShell it is /Command
let linuxPath = windowsPath.trim().replace(/^([a-zA-Z]):\\/, '/mnt/$1/').replace(/\\/g, '/'); | ||
executableArgs.push(linuxPath); | ||
// If win32 and bash.exe, transform Windows file path to Linux file path | ||
if (this.platform === 'win32' && executable.indexOf('bash.exe') !== -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't simply test bash.exe here since git under Window installs a bash.exe as well. We either need to test for the full path or better see how bash from git mount the drive and do the path magic as well.
Haven't forgotten about this. Haven't had time lately. Will try to wrap this up this week. |
Attempting to re-create local dev environment to work on this pull request. Running into this bug #29310 |
I suspect I'm not knowledgeable enough in the Windows environment yet to auto-detect the various possible shells and how to differentiate Git bash.exe from WSL bash.exe. Would you accept and merge this PR were it only to allow |
Detect msys Git Bash
I've made an attempt to honor ComSpec setting. I'm also setting correct shell args if cmd.exe, powershell.exe, or bash.exe. If bash.exe, I'm inspecting |
@codeguy sorry for not coming back earlier but I was very busy with Tasks 2.0.0. And now I am about to heading out on vacation until beginning of August. Will look at the PR then. |
Would love to see this added. Any update on the progress? |
My work on this has stalled and I do not have availability any time soon to continue work on it. Someone is welcome to pick up where I left off or work on an alternative PR. |
any update on this? |
There is now a general item on the VS Code roadmap to improve WSL support. |
Excuse me, could you be more specific? What are the configurations? |
We have not agreed on a concrete set of scenarios yet (see https://github.com/Microsoft/vscode/wiki/Roadmap#wsl-support) But being able to launch tooling in WSL (for example php executable is on the list). |
Related to #22391
WORK IN PROGRESS. DO NOT MERGE YET.
I am having an issue fetching the standard output from the spawned validator process. What I am doing is spawning a cmd.exe process, and that spawns a bash.exe process who in turn runs "php -l -n -f /path/to/file/to/validate.php". However, this callback is never called:
https://github.com/codeguy/vscode/blob/feature-wsl-php-validator/extensions/php/src/features/validationProvider.ts#L284-L287
I have not hooked up custom configuration settings yet. I am simply forcing VSCode to use WSL php for validation with these temporary lines:
https://github.com/codeguy/vscode/blob/feature-wsl-php-validator/extensions/php/src/features/validationProvider.ts#L252-L265
Do you have any thoughts why I am not getting any stdout?
I have seen this issue with WSL:
cpdt/slinky#11Correct issue to reference is microsoft/WSL#2
But that was apparently resolved with latest code pushed out with Creators Update.
Thoughts?
Wasn't sure which branch to send PR against, so using master for now. I can always re-submit.