Sublime Forum

Using phpcs with SublimeLinter no longer working?

#1

Hi folks,
Been using ST (on MacOS) for a while, but lately it seemed like my phpcs checks weren’t running properly. I’ve got Build 4180, and finally figured out that PackageControl needed an update, so I have all packages up to date.
At any rate, I’ve enabled debugging for SublimeLinter, and it says this:
SublimeLinter: #5 linter.py:1240 phpcs: output:
ERROR: option "- " not known

Run “phpcs --help” for usage information
SublimeLinter: #5 linter.py:1292 phpcs: No match for line: ‘ERROR: option "- " not known’
SublimeLinter: #5 linter.py:1292 phpcs: No match for line: ‘’
SublimeLinter: #5 linter.py:1292 phpcs: No match for line: ‘Run “phpcs --help” for usage information’
SublimeLinter: #5 linter.py:1292 phpcs: No match for line: ‘’

If I run the same phpcs command in Terminal, it outputs the proper phpcs errors just fine. So something in ST is running the command differently, and I’m not sure what/where?

0 Likes

#2

Do you mean you run this, which has the trailing -? Do you have custom settings for SublimeLinter-phpcs?

One thing I noticed is that there is an extra space after - in the error message.

0 Likes

#3

In the debug console, it shows the full command that it ran:
cat ewww-image-optimizer.php | /Users/sbishop/deploy/vendor/bin/phpcs --report=emacs --standard=phpcs.ruleset.xml -d memory_limit=512M --stdin-path=/Users/sbishop/Documents/GitHub/ewww-image-optimizer/ewww-image-optimizer.php -

If I just copy and paste that into Terminal, it works, and there’s no space after the “-” in the command otherwise, so I’m not certain where that extra space comes from. Checking the phpcs help, it states that “-” is supported for reading from STDIN, so it certainly ought to work.

0 Likes

#4

Having no idea what happened since both SublimeLinter and SublimeLinter-phpcs have no recent new release.

0 Likes

#5

I should clarify, that it’s probably been broken for a while, but I just didn’t have time to dig into it. Everything always says “ok” so the only time I knew there was an issue was when our automated testing caught it.

My PackageControl was busted since I was still on 3.x afaik, so nothing got updated until today.
Since SublimeLinter-phpcs hasn’t been updated in a long while, I’m guessing it’s something with SublimeLinter itself? Maybe I can try different releases and see what happens…

0 Likes

#6

I think I got it! Sometimes phpcs needs more memory than the default PHP config allows, so I had added the arg “-d memory_limit=512M” into the linter config.

That was bugging me, and I couldn’t get it out of my mind, so I removed that one arg, and now it works again! Now I’ll just have to pay attention to whether I hit memory limits again and see if there is a different/better way to increase the memory limit.

0 Likes

#7

maybe you can try the second style (list of strings).
https://www.sublimelinter.com/en/latest/linter_settings.html#args

0 Likes

#8

Ooh, hadn’t even thought to try a different style there! But I was already using a list of strings, so I changed it to a single string:

"args": "--standard=phpcs.ruleset.xml -d memory_limit=512M"

That worked, so now I don’t have to worry about the memory limit (hopefully)!

0 Likes