junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
356 stars 45 forks source link

env: php: No such file or directory #220

Open nagi1 opened 2 months ago

nagi1 commented 2 months ago

MacOS 13.6 M1

My log

runAsync: spawn /Users/nagi/.composer/vendor/bin/php-cs-fixer
[
  "fix",
  "--using-cache=no",
  "--format=json",
  "--config=/Users/nagi/code/xxx-service/.php-cs-fixer.php",
  "--path-mode=override",
  "/var/folders/kk/tnpyjvdd7gl_nt6gnvq442vr0000gn/T/pcf-tmp0.9868545293167241/PaopaController.php"
]
{
  "cwd": "/Users/nagi/code/xxx-service/app/Http/Controllers/Mamoth",
  "env": {
    "PHP_CS_FIXER_IGNORE_ENV": "1"
  },
  "shell": false
}
runAsync: error
{
  "exitCode": 127,
  "stdout": null,
  "stderr": "env: php: No such file or directory\n"
}
runAsync: reject promise
env: php: No such file or directory
nagi1 commented 2 months ago

Update 1: no matter the version same error Update 2: even if I changed the tmpdir to another dir same error The folder "pcf-tmp0.7077788343935298" and the file isnt there.

"/Users/nagi/temp/php-cs-fixer/pcf-tmp0.7077788343935298/PandaController.php"
itwondersteam commented 2 months ago

Changing vendor/bin/php-cs-fixer from

#!/usr/bin/env php

to existing php path

#!/usr/local/bin/php

will fix the issue.

The problem is that the default macOS path used is unable to find the php, and unable to copy PHP to any of the specified system protected folders. /usr/bin:/bin:/usr/sbin:/sbin/usr/bin:/bin:/usr/sbin:/sbin

Any better solution to this?

UPDATE: 2024-08-29 It's a false perception that setting #!/usr/local/bin/php fixed the error, as there's no longer an error reported in the output tab. However, the error still gets thrown in the 'Developer: Toggle Developer Tools' console.

The working solution for me is to set these two settings

  "php-cs-fixer.executablePath": "${extensionPath}/php-cs-fixer.phar",
  "terminal.integrated.env.linux": {
       "PATH": "...",
   }
DavidFox9000 commented 2 months ago

Having the same issue with the same output. None of the suggestions are working. I just got it set up and working a week or so ago and thought I was going crazy lol.