ikappas / vscode-phpcs

PHP CodeSniffer for Visual Studio Code
MIT License
128 stars 56 forks source link

"Unable to locate phpcs" with a global path including '~' #120

Open garrettw opened 6 years ago

garrettw commented 6 years ago

I'm on macOS. I installed phpcs globally with composer, and then added it to my global path by appending ~/.composer/vendor/bin to /etc/paths. After verifying in a new terminal that typing phpcs did in fact work, I restarted VS Code only to find that it still couldn't locate the executable. Interestingly enough, running which phpcs at this point gave me no output.

So I changed the line in /etc/paths to be /Users/username/.composer/vendor/bin, and VS Code no longer gave me that error. Also, which phpcs now gives me the expected output.

Is it possible for this extension to be made to work with a global path containing ~?

rbrisita commented 6 years ago

I am seeing the same error. Mac OS X 10.13.6 (17G65) PHPCS 3.3.1 Code 1.27.1 (1.27.1)

rbrisita commented 6 years ago

It seems that:

phpcs.executablePath

and

Phpcs: Executable Path
Optional. The path to the phpcs executable.

are not optional.

Current fix as stated by OP: "phpcs.executablePath": "/Users/${YOUR_USERNAME}/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs"

garrettw commented 6 years ago

Composer copies all "bin" files into one central location, so /Users/${YOUR_USERNAME}/.composer/vendor/bin is sufficient.

Also, I have phpcs working on a different machine without setting phpcs.executablePath -- so it is indeed optional if everything else involved works correctly.