benmatselby / sublime-phpcs

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

All attempts to sniff PHP files in ST2 error out #79

Closed prometheas closed 11 years ago

prometheas commented 11 years ago

I just can't seem to get this to work. Every time I try to sniff the code for a PHP file, I console shows the following:

[Phpcs] /usr/local/bin/phpcs --report=checkstyle -n --standard=PEAR /Users/yanni/Documents/Dropbox/Projects/seo-unit/src/Prometheas/SeoUnit/ScriptParser.php
[Phpcs] cwd: /Users/yanni
Exception in thread Thread-17:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 484, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./phpcs.py", line 398, in run
  File "./phpcs.py", line 128, in get_errors
  File "./phpcs.py", line 194, in execute
  File "./phpcs.py", line 197, in parse_report
  File "./phpcs.py", line 149, in shell_out
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

I am able to issue the command above into Terminal, and get the expected output, so phpcs itself seems to be functioning correctly.

Not sure if it makes a difference, but here's my version info:

Here's the sum of my complete user settings file:

{
    "phpcs_executable_path": "/usr/local/bin/phpcs",
    "phpmd_executable_path": "/usr/local/Cellar/php-md/1.4.1/libexec/phpmd.phar",
    "php_cs_fixer_executable_path": "/usr/local/Cellar/php-cs-fixer/0.2.0/libexec/php-cs-fixer.phar"
}
benmatselby commented 11 years ago

I've never seen this error running within ST2 on Windows, Linux or Mac.. A quick google brought up this result:

http://stackoverflow.com/questions/4834483/is-this-the-right-way-to-run-a-shell-script-inside-python

Is the PHP_CodeSniffer a standard install?

I've just done a fresh install of the plugin on ST2 on a Mac with PHP_CodeSniffer 1.4.5 and it is working as intended. This leads me back to the link above.

prometheas commented 11 years ago

Hah! Holy shit -- it was literally a missing shebang.

My file (installed via Homebrew) was originally just:

/usr/bin/env php /usr/local/Cellar/php-code-sniffer/1.4.5/scripts/phpcs $*

Adding #!/bin/bash made it work straight away. Man, I'm thrilled to finally have this working. Saturday's efforts made for a long day... thanks for getting me unstuck with that link, amigo.

Go on and close this guy up.

benmatselby commented 11 years ago

Thanks for getting back to me. So, my question here is, are all homebrew installations like this? If so I'll need to update the readme

prometheas commented 11 years ago

I just uninstalled and re-installed Homebrew's php-code-sniffer - the package does indeed come in without the shebang.