alecthomas / SublimeLinter-contrib-gometalinter

SublimeLinter plugin for gometalinter
MIT License
47 stars 13 forks source link

FileNotFoundError: [Errno 2] No such file or directory #16

Closed cixtor closed 6 years ago

cixtor commented 6 years ago

This exception is thrown when a section of the code with warnings or errors is copied into a new tab which initially lives in memory. The linter crashes during the execution of f.endswith('.go') because f seems to be referencing a file that doesn't exists [yet]. I can submit a pull-request fixing the bug, but recently SublimeLinter have been changing a lot of things in their API, things that may or may not affect this specific, because of this, I prefer to wait for the maintainer to decide what to do with this bug before touching the code.

Traceback (most recent call last):
  File "/SublimeLinter/lint/backend.py", line 97, in execute_lint_task
    errors = linter.lint(code, view_has_changed, settings) or []
  File "/SublimeLinter/lint/linter.py", line 797, in lint
    output = self.run(cmd, code)
  File "/SublimeLinter-gometalinter/linter.py", line 32, in run
    return self._live_lint(cmd, code)
  File "/SublimeLinter-gometalinter/linter.py", line 47, in _live_lint
    files = [f for f in os.listdir(dir) if f.endswith('.go')]
FileNotFoundError: [Errno 2] No such file or directory: ''

d

alecthomas commented 6 years ago

Ah I've seen that but hadn't figured out why it happened. Restarting Sublime seemed to fix it.

cixtor commented 6 years ago

A restart of the editor is not necessary, one could simply change the syntax of the current view.

However, this is simply a workaround. A real fix would be much appreciated, but I'm not sure how frequently people fall into this issue for you to consider adding the exception handler. I can submit a pull-request on Monday if you are willing to review the changes.

alecthomas commented 6 years ago

A restart of the editor is not necessary, one could simply change the syntax of the current view.

That doesn't make sense, in that it does fix it which it wouldn't if it were only triggered by an unsaved buffer, so it seems that there is probably some other trigger. Anyway, regardless, this should be fixed now.