Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
prometheas opened this issue May 19, 2013 · 4 comments
Closed

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

prometheas opened this issue May 19, 2013 · 4 comments

Comments

@prometheas
Copy link

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:

  • Sublime Text: 2.0.1, Build 2217
  • PHP_CodeSniffer 1.4.5

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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

benmatselby added a commit that referenced this issue May 20, 2013
@prometheas
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants