benmatselby / sublime-phpcs

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

Issues on Mac 10.7.3 #4

Closed baileylo closed 12 years ago

baileylo commented 12 years ago

Hey, can't seem to get it working correctly on my mac. Here's the debug information I could muster.

print sys.version 2.6.7 (r267:88850, Jul 31 2011, 19:30:54) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]

[Phpcs] phpcs --report=checkstyle -n --standard=PEAR /Users/loganbailey/Desktop/testScript.php Traceback (most recent call last): File "./sublimeplugin.py", line 350, in run File "./phpcs.py", line 192, in run File "./phpcs.py", line 141, in run File "./phpcs.py", line 61, in get_errors File "./phpcs.py", line 98, in execute File "./phpcs.py", line 101, in parse_report File "./phpcs.py", line 71, 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 2] No such file or directory

The issue comes from this line: https://github.com/benmatselby/sublime-phpcs/blob/master/phpcs.py#L71

I tried changing the line to the following:

            proc = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, shell=True)

That ran successfully, but the output is incorrect.

benmatselby commented 12 years ago

This seems to be a Python Framework issue with version 2.6 as I've tested on a few macs now all running Lion though and they all have version 2.7.. I will see if I can downgrade my python version to replicate the issue, can you try and upgrade your python version to 2.7?

benmatselby commented 12 years ago

Hi there, I've done some digging, and your versions are exactly the same as mine. I've tested on Snow Leopard and all works fine.. The only way I can replicate your error is if I uninstall PHP_CodeSniffer using Pear, do you have that installed?

Which build of Sublime Test 2 are you running?

baileylo commented 12 years ago

I upgraded to latest version of CodeSniffer via Pear. Copied latest extension code from the repo. I'm running on latest version of Lion.

benmatselby commented 12 years ago

OK, I'm a little baffled, as you have all the same versions as me now, and I've checked on the 3 macs I have access too and they all work fine..

Where is your phpcs command? Can you paste the location of that, plus your PATH and the permissions on your phpcs app in the bin folder?

baileylo commented 12 years ago
loganbailey@logan:~$ which phpcs
/Users/loganbailey/pear/bin/phpcs

loganbailey@logan:~$ ls -l /Users/loganbailey/pear/
total 0
drwxr-xr-x  14 loganbailey  staff  476 Mar  3 08:54 bin
drwxr-xr-x   2 loganbailey  staff   68 Sep 15 22:46 cfg
drwxr-xr-x   6 loganbailey  staff  204 Sep 15 22:48 data
drwxr-xr-x  16 loganbailey  staff  544 Sep 15 22:48 docs
drwxr-xr-x   3 loganbailey  staff  102 Sep 15 22:46 share
drwxr-xr-x   5 loganbailey  staff  170 Sep 15 22:48 tests
drwxr-xr-x   2 loganbailey  staff   68 Sep 15 22:46 www
loganbailey@logan:~$ ls -l /Users/loganbailey/pear/bin/
total 88
-rwxr-xr-x  1 loganbailey  staff  1938 Sep 24 17:17 create_package.xml.php
-rwxr-xr-x  1 loganbailey  staff  2260 Sep 15 23:48 dbunit
-rwxr-xr-x  1 loganbailey  staff    91 Sep 24 17:17 generate_path.php
-rwxr-xr-x  1 loganbailey  staff   906 Sep 15 23:48 pear
-rwxr-xr-x  1 loganbailey  staff   927 Sep 15 23:49 peardev
-rwxr-xr-x  1 loganbailey  staff   843 Sep 15 23:49 pecl
-rwxr-xr-x  1 loganbailey  staff  2245 Sep 15 23:49 phpcov
-rwxr-xr-x  1 loganbailey  staff  1213 Mar  3 08:54 phpcs
-rwxr-xr-x  1 loganbailey  staff  2244 Sep 15 23:49 phptok
-rwxr-xr-x  1 loganbailey  staff  2110 Sep 15 23:47 phpunit
drwxr-xr-x  3 loganbailey  staff   102 Mar  3 08:54 scripts
-rwxr-xr-x  1 loganbailey  staff  2023 Sep 24 17:17 update_package.xml.php

I think I got all that you were asking for, if you need anything else just ask.

baileylo commented 12 years ago
class Sniffer(ShellCommand):
    """Concrete class for PHP_CodeSniffer"""
    def execute(self, path):
        args = ['/Users/loganbailey/pear/bin/phpcs']

That seemed to solve my issues.

benmatselby commented 12 years ago

That makes sense as it looks like it simply couldn't find phpcs on your PATH. I'm going to install phpcs in my home directory and see if that helps me replicate your issue. So for now that change makes it work for you?

benmatselby commented 12 years ago

Logan,

I've added an option to the configuration file "phpcs_executable_path" which if not empty will use the path to the command.. It's on the "GH-4" branch, could you see if this helps you out.. I've only had chance to test it on my macbook at the moment, but if this works for you without needing to change the Python code, I will test on the other platforms and update the master branch..

Thanks

baileylo commented 12 years ago

That work perfectly. Thanks!

benmatselby commented 12 years ago

Now pushed to master branch so should be available in Package Control as an update as well