benmatselby / sublime-phpcs

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

PHPCBF doesn't execute when executed on save #132

Closed sataris closed 9 years ago

sataris commented 9 years ago

When trying to execute phpcbf on save, nothing happens.

Enabling debug produces the following output

=> Fixing file: 2/2 violations remaining

=> Fixing file: 2/2 violations remaining [made 1 pass]... 

=> Fixing file: 2/2 violations remaining [made 2 passes]... 

=> Fixing file: 0/2 violations remaining [made 3 passes]... DONE in 43ms

Array ( [0] => Ignoring potentially dangerous file name /var/www/file.php [1] => can't find file to patch at input line 3 [2] => Perhaps you used the wrong -p or --strip option? [3] => The text leading up to this was: [4] => -------------------------- [5] => |--- /var/www/file.php [6] => |+++ PHP_CodeSniffer [7] => -------------------------- [8] => File to patch: [9] => Skip this patch? [y] [10] => Skipping patch. [11] => 1 out of 1 hunk ignored ) Returned: 1 Time: 89ms; Memory: 4.5Mb

Here are my settings

{ "phpcbf_executable_path": "phpcbf", "phpcbf_on_save": true, "show_debug": true, "phpcbf_additional_args": { "--standard": "PSR2", }, }

benmatselby commented 9 years ago

Hi there @sataris - This looks to be a phpcbf error, and not the plugin?

sataris commented 9 years ago

@benmatselby , which is strange as I can execute it from the terminal just fine,

If i run the command that's output in the debug (ie. the normal phpcbf command)

[Phpcs] phpcbf /var/www/file.php --standard=PSR2

Everything works fine,

Processing file.php [PHP => 191 tokens in 28 lines]... DONE in 13ms (1 fixable violations) => Fixing file: 0/1 violations remaining [made 3 passes]... DONE in 43ms Patched 1 file Time: 91ms; Memory: 4.75Mb

sataris commented 9 years ago

Could it be a permission issue, where it can't write the diff file?

sataris commented 9 years ago

Heh, running the phpcbf in sublime with the --no-patch argument does indeed correct the issue.

Though I'm at a loss to explain why it can't write the diff file.

benmatselby commented 9 years ago

Sorry, cannot really help with that. I haven't come across those issues when I added the functionality, but I don't use that tool daily to be honest.

ADmad commented 9 years ago

I also encountered the same issue, thanks for the workaround @sataris.

MartinLyne commented 9 years ago

I'm seeing this when running from inside vim on ubuntu, on a whim I tried cding to the directory's parent and tried again, it seemed to work. Something to do with having "up a level" in the path?

Might help someone else who lands here, probably won't help OP though.

dereuromark commented 8 years ago

Same annoying issue here, thanks for the --no-patch workaround!

gmponos commented 7 years ago

I also ecountered this problem but I think the issue is on codesniffer. Thanks about the --no-patch option it was very helpful. I could not find anything in codesniffer.

oleksandrmakhno commented 7 years ago

--no-patch also works for me, run from terminal