junstyle / vscode-php-cs-fixer

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

Unable to run in docker #178

Closed cartok closed 2 years ago

cartok commented 2 years ago

Hey, projects usually run in docker and you do not want the developers to install the tools manually. I've tried to set the executablePath with docker exec and docker-compose run but it won't work as it has to be a file path to an executable. So I've tried it with a shell script which executes the command but it still won't work, the final command must be wrong.

I think it would be good to add an extra option for docker executable.

junstyle commented 2 years ago

i don't know where you vscode running. you can open vscode's Developer Tools, and see the args passed to php-cs-fixer. the args contains the file path. you must make sure php-cs-fixer can read the file

cartok commented 2 years ago

Nevermind, it could be complicated I guess, the temporary file would also need to be made available inside of docker?

junstyle commented 2 years ago

yes, make sure php-cs-fixer can read the tmp file

cartok commented 2 years ago

I might try it out another day, thanks @junstyle

FranciscoCaldeira commented 1 year ago

you can open vscode's Developer Tools, and see the args passed to php-cs-fixer.

Hello @junstyle , I have the same problem (php-cs-fixer:failed because executablePath), this is my developer tools where I see the args passed ?

Attach of img: imagem

Thanks!

cavo789 commented 1 year ago

Hello

Same problem for me. I'm using php-cs-fixer from a Docker image and here is my command line docker run --rm jakzal/phpqa:1.79.2-php8.1 php-cs-fixer <A LOT OF ARGUMENTS>.

So, php-cs-fixer isn't installed on my machine, I'm using it through a Docker image and it's working on the command line.

If I try to put this in my settings.json, it fails saying PHP CS Fixer: executablePath not found and my setting is resetted to "${extensionPath}/php-cs-fixer.phar" (but I don't have it on my machine)

{
    "php-cs-fixer.executablePath": "docker run --rm jakzal/phpqa:1.79.2-php8.1 php-cs-fixer"
}

Did you think something can be done here i.e. allow to specify a command line instead of a file?

junstyle commented 1 year ago

docker container must have permissions to read/write the files in host ( /tmp/pcf-tmp-xxxxxxxx and config file). but i don't know the result output from docker run. welcom pr

cavo789 commented 1 year ago

Thanks for your answer and your unvaluable tool and work.

The problem isn't about the execution (i can run it manually from inside the container). The problem is vscode ; I don't know how it is done but vscode seems to search for the binary and that one didn't exists on my machine since I'm running it using Docker.

It's something like "Better PhpUnit", a vscode extension. There a settings exists to tell the addon to use a docker executable path.

Note : I perfectly understand it's terribly specialized and more about vscode and the addon, not your tool.