formulahendry/vscode-code-runner

Bash on Ubuntu on Windows php problem

Open

#105 opened on Apr 18, 2017

 (3 comments) (0 reactions) (0 assignees)TypeScript (343 forks)github user discovery
help wanted

Repository metrics

Stars
 (2,408 stars)
PR merge metrics
 (PR metrics pending)

Description

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?

Contributor guide