dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.58k stars 1.44k forks source link

Macvim does not run MDL linter #2528

Closed teoljungberg closed 5 years ago

teoljungberg commented 5 years ago

Information

VIM version

VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 18 2019 23:51:40)
macOS version
Included patches: 1-950     

Operating System: macOS 10.14.4 (18E226)

What went wrong

The linter mdl doesn't work in MacVim on macOS with :ALELint, it does work when I do :!bin/mdl path/to/file.md and outputs the linting warnings as expected. It does work with the same configuration for terminal vim.

Reproducing the bug

:ALEInfo

 Current Filetype: markdown
Available Linters: ['alex', 'languagetool', 'markdownlint', 'mdl', 'proselint', 'redpen', 'remark_lint', 'textlint', 'vale', 'writegood']
   Linter Aliases:
'remark_lint' -> ['remark-lint']
'writegood' -> ['write-good']
  Enabled Linters: ['mdl']
 Suggested Fixers: 
  'prettier' - Apply prettier to a file.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'textlint' - Fix text files with textlint --fix
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_markdown_mdl_executable = 'bin/mdl'
let g:ale_markdown_mdl_options = ''
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = v:null
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {'elixir': ['mix_format'], '*': ['trim_whitespace'], 'javascript': ['eslint'], 'rust': ['rustfmt'], 'ruby': ['rubocop']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 0
let g:ale_lint_on_filetype_changed = 0
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 0
let g:ale_linter_aliases = {}
let g:ale_linters = {'vim': ['vint'], 'elixir': ['credo'], 'markdown': ['mdl'], 'sh': ['shellcheck'], 'ruby': ['rubocop'], 'javascript': ['eslint']}
let g:ale_linters_explicit = 1
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = v:null
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 1
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 1
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 0
let g:ale_sign_column_always = v:null
let g:ale_sign_error = v:null
let g:ale_sign_info = v:null
let g:ale_sign_offset = v:null
let g:ale_sign_style_error = v:null
let g:ale_sign_style_warning = v:null
let g:ale_sign_warning = v:null
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) bin/mdl
(finished - exit code 1) ['/bin/zsh', '-c', '''bin/mdl'' < ''/var/folders/k6/vjy3s3lj7hg9wptzjrcnmcww0000gn/T/v5tEbnr/10/README.md''']

<<<NO OUTPUT RETURNED>>>

The output of `:!bin/mdl %

:!bin/mdl docs/policies/README.md
docs/policies/README.md:7: MD022 Headers should be surrounded by blank lines

A detailed description of the rules is available at https://github.com/markdownlint/ma
rkdownlint/blob/master/docs/RULES.md

shell returned 1
w0rp commented 5 years ago

Try setting g:ale_markdown_mdl_executable to an absolute path to the executable, and see if that works. If that doesn't work, try editing ale_linters/markdown/mdl.vim and add \ 'output_stream': 'both', to the options at the bottom of the file like some other linters, and see if that fixes it. Let me know what happens.

teoljungberg commented 5 years ago

I tried changing g:ale_markdown_mdl_executable to an absolute path, same outcome.

 Current Filetype: markdown
Available Linters: ['alex', 'languagetool', 'markdownlint', 'mdl', 'proselint', 'redpen', 'remark_lint', 'textlint', 'vale', 'writegood']
   Linter Aliases:
'remark_lint' -> ['remark-lint']
'writegood' -> ['write-good']
  Enabled Linters: ['mdl']
 Suggested Fixers: 
  'prettier' - Apply prettier to a file.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'textlint' - Fix text files with textlint --fix
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_markdown_mdl_executable = '/path/to/repo/bin/mdl'
let g:ale_markdown_mdl_options = ''
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = v:null
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {'elixir': ['mix_format'], '*': ['trim_whitespace'], 'javascript': ['eslint'], 'rust': ['rustfmt'], 'ruby': ['rubocop']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 0
let g:ale_lint_on_filetype_changed = 0
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 0
let g:ale_linter_aliases = {}
let g:ale_linters = {'vim': ['vint'], 'elixir': ['credo'], 'markdown': ['mdl'], 'sh': ['shellcheck'], 'ruby': ['rubocop'], 'javascript': ['eslint']}
let g:ale_linters_explicit = 1
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = v:null
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 1
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 1
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 0
let g:ale_sign_column_always = v:null
let g:ale_sign_error = v:null
let g:ale_sign_info = v:null
let g:ale_sign_offset = v:null
let g:ale_sign_style_error = v:null
let g:ale_sign_style_warning = v:null
let g:ale_sign_warning = v:null
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) /path/to/repo/bin/mdl
(finished - exit code 1) ['/bin/zsh', '-c', '''/path/to/repo/bin/mdl'' < ''/var/folders/k6/vjy3s3lj7hg9wptzjrcnmcww0000gn/T/vvIrGdb/10/README.md''']

<<<NO OUTPUT RETURNED>>>

However, changing the output_stream I got this output:

 Current Filetype: markdown
Available Linters: ['alex', 'languagetool', 'markdownlint', 'mdl', 'proselint', 'redpen', 'remark_lint', 'textlint', 'vale', 'writegood']
   Linter Aliases:
'remark_lint' -> ['remark-lint']
'writegood' -> ['write-good']
  Enabled Linters: ['mdl']
 Suggested Fixers: 
  'prettier' - Apply prettier to a file.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'textlint' - Fix text files with textlint --fix
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_markdown_mdl_executable = 'bin/mdl'
let g:ale_markdown_mdl_options = ''
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = v:null
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {'elixir': ['mix_format'], '*': ['trim_whitespace'], 'javascript': ['eslint'], 'rust': ['rustfmt'], 'ruby': ['rubocop']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 0
let g:ale_lint_on_filetype_changed = 0
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 0
let g:ale_linter_aliases = {}
let g:ale_linters = {'vim': ['vint'], 'elixir': ['credo'], 'markdown': ['mdl'], 'sh': ['shellcheck'], 'ruby': ['rubocop'], 'javascript': ['eslint']}
let g:ale_linters_explicit = 1
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = v:null
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 1
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 1
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 0
let g:ale_sign_column_always = v:null
let g:ale_sign_error = v:null
let g:ale_sign_info = v:null
let g:ale_sign_offset = v:null
let g:ale_sign_style_error = v:null
let g:ale_sign_style_warning = v:null
let g:ale_sign_warning = v:null
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) bin/mdl
(finished - exit code 1) ['/bin/zsh', '-c', '''bin/mdl'' < ''/var/folders/k6/vjy3s3lj7hg9wptzjrcnmcww0000gn/T/vjHhVwb/10/README.md''']

<<<OUTPUT STARTS>>>
path-to-repo/.bundle/vendor/gems/kramdown-1.17.0/lib/kramdown/parser/base.rb:95:in `encode': "\xE2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
    from path-to-repo/.bundle/vendor/gems/kramdown-1.17.0/lib/kramdown/parser/base.rb:95:in `adapt_source'
    from path-to-repo/.bundle/vendor/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:89:in `parse'
    from path-to-repo/.bundle/vendor/gems/kramdown-1.17.0/lib/kramdown/parser/base.rb:69:in `parse'
    from path-to-repo/.bundle/vendor/gems/kramdown-1.17.0/lib/kramdown/document.rb:104:in `initialize'
    from path-to-repo/.bundle/vendor/gems/mdl-0.5.0/lib/mdl/doc.rb:45:in `new'
    from path-to-repo/.bundle/vendor/gems/mdl-0.5.0/lib/mdl/doc.rb:45:in `initialize'
    from path-to-repo/.bundle/vendor/gems/mdl-0.5.0/lib/mdl/doc.rb:55:in `new'
    from path-to-repo/.bundle/vendor/gems/mdl-0.5.0/lib/mdl/doc.rb:55:in `new_from_file'
    from path-to-repo/.bundle/vendor/gems/mdl-0.5.0/lib/mdl.rb:76:in `block in run'
    from path-to-repo/.bundle/vendor/gems/mdl-0.5.0/lib/mdl.rb:74:in `each'
    from path-to-repo/.bundle/vendor/gems/mdl-0.5.0/lib/mdl.rb:74:in `run'
    from path-to-repo/.bundle/vendor/gems/mdl-0.5.0/bin/mdl:10:in `<top (required)>'
    from bin/mdl:29:in `load'
    from bin/mdl:29:in `<main>'
<<<OUTPUT ENDS>>>

So it looks like an encoding issue - and my encoding is forced to set encoding=utf-8 I can see with echo &encoding.

Any other pointers of where to start looking?

teoljungberg commented 5 years ago

Interestingly enough it's a dependency on the rubygems that has the encoding issue.

w0rp commented 5 years ago

Maybe you need to change your environment variables for zsh to set a different encoding. Sounds like a bug in mdl.

teoljungberg commented 5 years ago

Forcing my LANG in zsh from en_US to en_US.UTF-8 did the trick.

Thanks for helping me debug this @w0rp!

w0rp commented 5 years ago

No problemo. :+1: