benmatselby / sublime-phpcs

🔍 PHP CodeSniffer, PHP Coding Standard Fixer, Linter, and Mess Detector Support for Sublime Text
Other
812 stars 126 forks source link

What file it cannot find [WinError 2]? #205

Closed zigi05 closed 1 year ago

zigi05 commented 1 year ago

OS: Windows 10

Steps I did:

  1. Installed sublime-phpcs via package control.
  2. Installed phpcs and phpmd globally via composer.
  3. Made sure composer vendor bin is in PATH.

When I save a file in sublime, get an error that the system cannot find a file. What file it cannot find, where should I look?

Here's the output:

Exception in thread Thread-5:
Traceback (most recent call last):
  File "./python3.3/subprocess.py", line 1104, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./python3.3/threading.py", line 901, in _bootstrap_inner
  File "./python3.3/threading.py", line 858, in run
  File "C:\Users\xxx\AppData\Roaming\Sublime Text\Installed Packages\Phpcs.sublime-package\phpcs.py", line 488, in run
    self.checkstyle_reports.append(['Sniffer', Sniffer().get_errors(path), 'dot'])
  File "C:\Users\xxx\AppData\Roaming\Sublime Text\Installed Packages\Phpcs.sublime-package\phpcs.py", line 149, in get_errors
    self.execute(path)
  File "C:\Users\xxx\AppData\Roaming\Sublime Text\Installed Packages\Phpcs.sublime-package\phpcs.py", line 231, in execute
    self.parse_report(args)
  File "C:\Users\xxx\AppData\Roaming\Sublime Text\Installed Packages\Phpcs.sublime-package\phpcs.py", line 234, in parse_report
    report = self.shell_out(args)
  File "C:\Users\xxx\AppData\Roaming\Sublime Text\Installed Packages\Phpcs.sublime-package\phpcs.py", line 176, in shell_out
    proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, startupinfo=info, cwd=self.workingDir)
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1110, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
benmatselby commented 1 year ago

Hey @zigi05 Does the information here help point you in the right direction?

zigi05 commented 1 year ago

@benmatselby ok, I've put "phpcs_executable_path": "C:/Users/xxx/AppData/Roaming/Composer/vendor/bin", which contains files shown on the screenshot below. I've also tried with a path to C:/Users/xxx/phpcs/phpcs.phar that I downloaded via curl.

In both cases I get the following error now:

OSError: [WinError 193] %1 is not a valid Win32 application

image

benmatselby commented 1 year ago

Hmm, I'm going to struggle to help here, I think. I don't have access to a windows machine, nor use Sublime Text anymore. Apologies.

zigi05 commented 1 year ago

On windows the path should point to .bat file, like this: C:/Users/xxx/AppData/Roaming/Composer/vendor/bin/phpcs.bat