I'm using WSL2, Ubuntu 20.04 and running VSCode. I'm using the Code Runner extension with VSCode and XAMPP on Windows
I set the path of php.exe in Windows environment variables.
I have the following in my VSCode settings.json in the code runner
"code-runner.executorMap": { "javascript": "node", "php": "C:\xampp\php\php.exe", "python": "python", "perl": "perl", "ruby": "C:\Ruby23-x64\bin\ruby.exe", "go": "go run", "html": "\"C:\Program Files\Mozilla Firefox\firefox.exe\"", "java": "cd $dir && javac $fileName && java $fileNameWithoutExt", "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", },
I have a program called index.php in the editor. I right-clicked in the VSCode editor and selected "Run Code"
In the output window of the VSCode terminal, I receive the following error message:
[Running] C:\xampp\php\php.exe "/home/johnr/xproj/index.php" /bin/sh: 1: C:xamppphpphp.exe: not found [Done] exited with code=127 in 0.039 seconds
I tried various configuration changes based on Google search results, but nothing changed this error message.
Unless I change sh dash to sh bash and get this message
[Running] C:\xampp\php\php.exe "/home/johnr/xproj/index.php" /bin/sh: C:xamppphpphp.exe: not found [Done] exited with code=127 in 0.039 seconds
The only difference is 1: does not exist after /bin/sh:
I think WSL requires a Unix-like path, so for example your php path should be
"php": "/mnt/c/xampp/php/php.exe",
instead of
"php": "C:\\xampp\\php\\php.exe",
The same situation may apply to ruby.