-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Is it possible to use wsl bash php for php.validate.executablePath #22391
Comments
In principal yes. However you need to use the |
Following up on this since I cannot get it to work here using Windows Creators Update, WSL enabled, with latest VSCode. I have set |
I also tried using https://neosmart.net/blog/2017/meet-your-new-best-friend-for-wsl/ |
@codeguy you are right. It doesn't work. I forgot to consider that we besides the pure executable pass additional command line arguments to the executable. These arguments make the bash start fail. To fix this we need to add an additional property to the configuration to request validation in a shell. Something like |
@codeguy would you be willing to work on a PR for this. The code is here: https://github.com/Microsoft/vscode/blob/master/extensions/php/src/features/validationProvider.ts#L248 |
For sure! I'll fork and work on it later today. |
See #25576 |
@codeguy Great. Will look at the PR. |
This is possible with an old school .bat :
setting.json |
While I am happy to see that this problem is being addressed I managed to put together two workaround scripts as I could not get any of the scripts found online to work (like the one posted by @tooy). This one is called @echo OFF
setlocal ENABLEDELAYEDEXPANSION
rem Collect the arguments and replace:
rem '\' with '/'
rem 'c:' with 'mnt/c'
rem '"' with '\"'
set v_params=%*
set v_params=%v_params:\=/%
set v_params=%v_params:C:=/mnt/c%
set v_params=%v_params%
set v_params=%v_params:"=\"%
rem Call the windows-php inside WSL.
rem windows-php is just a script which passes the arguments onto
rem the original php executable and converts its output from UNIX
rem syntax to Windows syntax.
C:\Windows\sysnative\bash.exe -l -c "windows-php %v_params%" This one is called # Pass all the arguments to PHP.
output=$(php "$@")
# Perform UNIX->WINDOWS syntax replacements.
output="${output//$'\n'/$'\r'$'\n'}"
output="${output//\/mnt\/c/C:}"
output="${output//\//\\}"
# Echo corrected output.
echo $output Setting |
@dbaeumer Is this still needed? Did you look at the PR? |
@roblourens that slipped through the cracks. I will look at the PR but in general we should look into a more generic solution to WSL than this. And what is about the PHP language server. Does that report errors and might make the start of the php executable obsolete ? |
I don't believe any of the PHP intellisense extensions have done any work in particular to support WSL. If this is hard to land, I won't push for it. I'd rather see the extensions implement it, but I don't see anyone filing issues on them for it. |
Any news about this? Thanks. |
No news yet on this particular item. But we started thinking about how we could better support WSL to make these errors be handled more generically than on a extension by extension base. |
Any update? :) |
@GioBonvi i've replaced the last line with |
@neyronius It works, thank you. |
"php.validate.executablePath": "wsl php" |
I was excited about @GioBonvi & @neyronius batch script fix for this until I tried it and god "Error spawning PHP: Command failed: C:\Dev\Scripts\wsl\php.bat --version zsh:1: command not found: php" so I guess if you have zsh or something similar installed, this work-around won't work... Any news on official wsl php support? |
@resonancedesigns I also added The scripts are in
php.bat @echo OFF
setlocal ENABLEDELAYEDEXPANSION
rem Collect the arguments and replace:
rem '\' with '/'
rem 'd:' with 'mnt/d'
rem '"' with '\"'
set v_params=%*
set v_params=%v_params:\=/%
set v_params=%v_params:D:=/mnt/d%
set v_params=%v_params%
set v_params=%v_params:"=\"%
rem Call the windows-php inside WSL.
rem windows-php is just a script which passes the arguments onto
rem the original php executable and converts its output from UNIX
rem syntax to Windows syntax.
C:\Windows\system32\bash.exe -l -c "windows-php %v_params%" windows-php #!/bin/bash
# Pass all the arguments to PHP.
output=$(php "$@")
# Perform UNIX->WINDOWS syntax replacements.
output="${output//$'\n'/$'\r'$'\n'}"
output="${output//\/mnt\/d/D:}"
output="${output//\//\\}"
# Echo corrected output.
echo $output And here are the settings inside VSCode: "php.validate.executablePath": "d:\\wsl-tools\\php.bat", |
@ianzhi 请看清楚 @GioBonvi 和 @tanmancan 的解决方案。。。 |
ok,tks |
We just announced remote development with VS Code, check out the blog post for details https://code.visualstudio.com/blogs/2019/05/02/remote-development |
How does remote development solve this issue? What is the setting for php.validateexecutablePath now? |
See some details about developing in WSL here: https://code.visualstudio.com/docs/remote/wsl In that scenario, that setting would be the path to PHP on the WSL side. |
|
I don't know why the people like to wrote very short words with link which is very long history. The solution correctly is:
NOW YOU CAN ENJOY YOUR VSCODE IN WSL |
Can Someone Clarify to me if i can use my php in WSL ?
The text was updated successfully, but these errors were encountered: