dense-analysis/ale

ALE still not working in MacVIM - have new information!!!

Closed this issue · 9 comments

synic commented

I think we are finally getting somewhere. I can see an error that's different this time.

Python syntax checking works in the CLI version of VIM, but not MacVim. This also happens to me on linux with gvim, but still works in the CLI.

I am getting this error:

 Current Filetype: python
Available Linters: ['flake8', 'mypy', 'pycodestyle', 'pylint']
  Enabled Linters: ['flake8', 'mypy', 'pylint']
 Linter Variables:

let g:ale_python_flake8_executable = 'flake8'
let g:ale_python_flake8_options = ''
let g:ale_python_flake8_use_global = 0
let g:ale_python_mypy_executable = 'mypy'
let g:ale_python_mypy_options = ''
let g:ale_python_mypy_use_global = 0
let g:ale_python_pylint_executable = 'pylint'
let g:ale_python_pylint_options = ''
let g:ale_python_pylint_use_global = 0
 Global Variables:

let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%s'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_open_list = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 1
let g:ale_sign_error = '>>'
let g:ale_sign_offset = 1000000
let g:ale_sign_warning = '--'
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(started) ['/usr/local/bin/zsh', '-c', '''flake8'' --format=default --stdin-display-name ''/Users/adam.olsen/Projects/eventboard.io/apps/accounts/drf/signup.py'' - < ''/var/folders/24/tbc7_m_n5ys52x70s9g_phq800010_/T/vBy8HZE/15/signup.py''']
(executable check - failure) mypy
(executable check - failure) pylint
(finished - exit code 1) ['/usr/local/bin/zsh', '-c', '''flake8'' --format=default --stdin-display-name ''/Users/adam.olsen/Projects/eventboard.io/apps/accounts/drf/signup.py'' - < ''/var/folders/24/tbc7_m_n5ys52x70s9g_phq800010_/T/vBy8HZE/16/signup.py''']

<<<OUTPUT STARTS>>>
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/flake8/main/cli.py", line 16, in main
    app.run(argv)
  File "/usr/local/lib/python2.7/site-packages/flake8/main/application.py", line 328, in run
    self._run(argv)
  File "/usr/local/lib/python2.7/site-packages/flake8/main/application.py", line 315, in _run
    self.initialize(argv)
  File "/usr/local/lib/python2.7/site-packages/flake8/main/application.py", line 299, in initialize
    self.parse_configuration_and_cli(argv)
  File "/usr/local/lib/python2.7/site-packages/flake8/main/application.py", line 168, in parse_configuration_and_cli
    self.option_manager, argv
  File "/usr/local/lib/python2.7/site-packages/flake8/options/aggregator.py", line 47, in aggregate_options
    original_values.isolated)
  File "/usr/local/lib/python2.7/site-packages/flake8/options/config.py", line 281, in parse
    return self.merge_user_and_local_config()
  File "/usr/local/lib/python2.7/site-packages/flake8/options/config.py", line 245, in merge_user_and_local_config
    config = self.parse_local_config()
  File "/usr/local/lib/python2.7/site-packages/flake8/options/config.py", line 205, in parse_local_config
    config = self.config_finder.local_configs()
  File "/usr/local/lib/python2.7/site-packages/flake8/options/config.py", line 107, in local_configs
    config, found_files = self._read_config(self.local_config_files())
  File "/usr/local/lib/python2.7/site-packages/flake8/options/config.py", line 56, in _read_config
    found_files = config.read(files)
  File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/backports/configparser/__init__.py", line 704, in read
    with open(filename, encoding=encoding) as fp:
LookupError: unknown encoding: 
<<<OUTPUT ENDS>>>

(executable check - failure) mypy
(executable check - failure) pylint
w0rp commented

I guess you need to fix the encoding in that file.

synic commented

It happens no matter what encoding I use, and only in the gui version

synic commented

It also happens if put no encoding.

w0rp commented

You probably need to set the encoding for your Python file. See the documentation here: https://docs.python.org/3/howto/unicode.html

I don't believe anything can be done about this here.

synic commented

Look, I get that you don't want this to be your problem, but please hear me out. I'm sure I'm not the only one this is happening to.

Again, I said no matter what # -*- encoding: utf-8 -*- in the python file, this error happens, but only when using MacVim. Why does it work in the CLI? What's the difference? If it works in one, why doesn't it work in the other, and how would it be the file encoding?

If you read the stacktrace, this is flake8 trying to read the configuration file. Yeah, it may have nothing to do with Ale at all, but I would think you would at least be curious. I'll go it on my own.

w0rp commented

You probably need to change the encoding used in some way. Possibly through environment variables. All ALE does is find the executable for flake8 and run it with a buffer. We can't control the behaviour beyond that.

w0rp commented

You can see a similar thing happening in Atom here: AtomLinter/linter-flake8#499

If anyone can propose some solution for this, I'll merge it, but I can't think of anything I can do about it.

synic commented

I found a solution:

$ sudo launchctl setenv LANG en_US.UTF-8
$ sudo launchctl setenv LC_ALL en_US.UTF-8

It appears OS X doesn't set these by default, and they are required for flake8 to be able to open it's own configuration file.

w0rp commented

Another Mac oddity. I might add that to an FAQ entry later. Thank you for the information!

This will actually be solved in Python 3.7, I believe. The default encoding will become UTF-8 on all platforms.