msherry / flycheck-pycheckers

Multiple syntax checker for Python in Emacs, using Flycheck
GNU General Public License v3.0
63 stars 23 forks source link

Executable not found on Windows #46

Closed sfavazza closed 4 years ago

sfavazza commented 4 years ago

The Issue

Hello! When I freshly install the flycheck-pycheckers package and enable it in elpy mode I got the following error whenever I visit a python file:

File mode specification error: (error Command executable for syntax checker python-pycheckers must be a string: nil)

I did my homework

After some investigation on the issue I realized that the flycheck-pycheckers-command variable is nil. This because the executable-find function seems not to find the pycheckers.py file. According to the emacs documentation, this command tries to look in all paths found in exec-path variable and to substitute all suffixes found in the exec-suffixes.

On my machine the exec-suffixes is set to: (".exe" ".com" ".bat" ".cmd" ".btm" "") As the empty string is included I thought it would have found the file, but no luck.

For test purposes I locally modified the offending statement as:

(defvar flycheck-pycheckers-command
  (executable-find (concat (file-name-directory (or load-file-name buffer-file-name))
                           "bin/pycheckers")))

And I added a batch script called pycheckers.bat in the same bin folder, from which I execute the python script:

python "%~dp0pycheckers.py" %*

So I manage to make it work, but I am looking for a more long-term elegant solution to this issue.

Has anybody ever get into this issue?

Cheers, Samuele

msherry commented 4 years ago

Thanks for the detailed report! I don't have a Windows machine to test or develop on, so unfortunately it might be a while before I can build out a fix. If you have something that works and want to turn it into a pull request, I'm happy to take a look at it!

sfavazza commented 4 years ago

Cool, I am working on my forked repo already. I got a working version with the hacks I mentioned in the previous post. I will soon propose a merge request.

Actually, as python 2.7 won't be officially supported anymore by the end on this year, would you mind if I make the code compatible with python 3?

sfavazza commented 4 years ago

After long time I got some time to spent on this issue, yet I didn't get your answer about the python 3 migration... Should we discuss this in another thread?

msherry commented 4 years ago

Sorry, I must have missed your earlier question. I'd be happy to accept a PR to make the code work correctly under python 3, but I'd want to make sure that it remains backwards-compatible for python 2.7, for people who haven't yet had the chance to migrate!

sfavazza commented 4 years ago

Well in that case it's already compatible, I always use python 3.

msherry commented 4 years ago

Going to close this issue out for lack of attention - please reopen if necessary.

grolongo commented 3 years ago

Hello,

I came accross that error when trying flycheck-pycheckers on Windows (same Emacs config works fine on macOS). I'm trying to use it with flake8 and bandit at the same time, both are in my path and functional from the command line (Powershell). Flake8 works without issue with Flycheck alone too. Is there any fix for this or a workaround available like OP suggested?

Thanks

msherry commented 3 years ago

Hi, @grolongo. Thanks for the report!

I suspect the default path for virtualenvs is not the same on Windows as it is on Linux/MacOS, but I don't have a windows machine handy to test with. Can you try debugging what path is being searched? I'm happy to accept pull requests, but I don't really have a way to debug this myself at the moment, unfortunately.

grolongo commented 3 years ago

@msherry hi, thanks for quick reply.

I would be happy to help but I'm very novice in Emacs/Elisp unfortunately. If you can provide me a debug command or quick guide I would gladly try to debug it and provide you the output of anything that can help fix this issue.