formulahendry/vscode-code-runner

Bash on Ubuntu on Windows php problem

Aperta

#105 aperta il 18 apr 2017

 (3 commenti) (0 reazioni) (0 assegnatari)TypeScript (343 fork)github user discovery
help wanted

Metriche repository

Star
 (2408 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

I've tried using PHP, installed in the Ubuntu subsystem on Windows 10, but it works partially.

I create the php.cmd file in PATH, which redirects the PHP command from the command line to bash Ubuntu (after replacing C:\ with /mnt/c/, replacing \ with / and escaping " characters). php.cmd:

@ECHO off
SET cmd=%*
SET cmd=%cmd:C:\=/mnt/c/%
SET cmd=%cmd:\=/%
SET cmd=%cmd:"=\"%
SET cmd=C:\Windows\System32\bash.exe -c "php %cmd%"
CALL %cmd%

This allows me to call from the command line (Windows) any php command (php -v; php "path_to_file"). However, this does not work with the code-runner, it outputs:

[Running] php "c:\temp\test.php"
"C:\Windows\System32\bash.exe" is not recognized as an internal or external command, 
operable program or batch file.

[Done] exited with code=1 in 0.028 seconds

In Windows shell (cmd, powershell) command php "c:\temp\test.php" works fine. What could be the reason?

Guida contributor