dense-analysis / ale

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

Setting "shellcmdflag" in .vimrc breaks ALE #3613

Open atsalolikhin-spokeo opened 3 years ago

atsalolikhin-spokeo commented 3 years ago

Information

VIM version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 19 2021 17:22:25)
macOS version
Included patches: 1-2164
Compiled by Homebrew

Operating System: macOS Big Sur 11.2.2

What went wrong

I added to my .vimrc:

" let me use bash aliases from within Vim
" (https://stackoverflow.com/questions/4642822/how-to-make-bashrc-aliases-available-within-a-vim-shell-command)
set shellcmdflag=-ic

and now when I am in Vim, I see messages like this at the bottom of my screen:

Error detected while processing function <SNR>57_VimCloseCallback[22]..function <SNR>57_VimCloseC
allback[15]..<lambda>4[1]..<SNR>55_ExitCallback[28]..<SNR>54_HandleExit[24]..ale_linters#markdown
#mdl#Handle[3]..ale#util#FuzzyJSONDecode:
line    8:
E491: json decode error at ']1337;RemoteHost=atsalolikhin@MB015-ATsalolikhin.local^G^[]1337;Curre
ntDir=/Users/atsalolikhin/git/work-log^G^[]1337;ShellIntegrationVersion=15;shell=bash^G[{"filenam
e":"(stdin)","line":3,"rule":"MD009","aliases":["no-trailing-spaces"],"description":"Trailing spa
ces"}]'

The error flashes briefly (for like a second) at the bottom of my screen, when I make changes to the file, or every once in a while. It's in red so it's very distracting.

If I remove the shellcmdflag setting, the error doesn't flash.

Reproducing the bug

  1. I added set shellcmdflag=-ic to my .vimrc
  2. The error started appearing in Vim

:ALEInfo


 Current Filetype: 
Available Linters: []
  Enabled Linters: []
  Ignored Linters: []
 Suggested Fixers: 
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

 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 = v:null
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 0
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = v:null
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 = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = v:null
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {'markdown': ['mdl']}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = v:null
let g:ale_list_window_size = v:null
let g:ale_loclist_msg_format = v:null
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = v:null
let g:ale_max_signs = v:null
let g:ale_maximum_file_size = v:null
let g:ale_open_list = v:null
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 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 = 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_sign_highlight_linenrs = v:null
let g:ale_statusline_format = v:null
let g:ale_type_map = v:null
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:
eToThePiIPower commented 1 week ago

I'm having the same error message on all files with filetype sh. For me, it doesn't seem to depend on the value of set shellcmdflag. The specific error I'm seeing is

Error detected while processing function <SNR>146_VimCloseCallback[11]..<SNR>146_VimExitCallback[22]..func
tion <SNR>146_VimCloseCallback[11]..<SNR>146_VimExitCallback[15]..<lambda>10[1]..<SNR>140_ExitCallback[28]
..<SNR>139_HandleExit[30]..ale#engine#HandleLocList[15]..ale#engine#FixLocList:
line 16:
E1098: String, List or Blob required
Error detected while processing function <SNR>146_VimCloseCallback:
line 11:
E171: Missing :endif

Snipping the ale-related output from :scriptnames:

130: ~/.vim/bundle/ale/autoload/ale/util.vim
131: ~/.vim/bundle/ale/autoload/ale/linter.vim
132: ~/.vim/bundle/ale/ale_linters/sh/bashate.vim
133: ~/.vim/bundle/ale/ale_linters/sh/cspell.vim
134: ~/.vim/bundle/ale/autoload/ale/handlers/cspell.vim
135: ~/.vim/bundle/ale/ale_linters/sh/language_server.vim
136: ~/.vim/bundle/ale/ale_linters/sh/shell.vim
137: ~/.vim/bundle/ale/ale_linters/sh/shellcheck.vim
138: ~/.vim/bundle/ale/autoload/ale/handlers/shellcheck.vim
139: ~/.vim/bundle/ale/autoload/ale/engine.vim
140: ~/.vim/bundle/ale/autoload/ale/command.vim
141: ~/.vim/bundle/ale/autoload/ale/history.vim
142: ~/.vim/bundle/ale/autoload/ale/path.vim
143: ~/.vim/bundle/ale/autoload/ale/lsp_linter.vim
144: ~/.vim/bundle/ale/autoload/ale/handlers/sh.vim
145: ~/.vim/bundle/ale/autoload/ale/semver.vim
146: ~/.vim/bundle/ale/autoload/ale/job.vim
147: ~/.vim/bundle/ale/autoload/ale/filetypes.vim

I've tracked down the error to a specific commit d63f5e6a from six months ago (14 Jaunary 2024), which roughly corresponds to when I began seeing this. The previous commit ebc6718c does not exhibit this error, while all future commits up to the current master (commit a0ad5f93) do.

Oddly, none of the files referenced in the error messag (146: job.vim, 140: command.vim, and 139: engine.vim) appear to have been touched in commit d63f5e6a, so I'm not sure where to proceed from here in tracking down the error.