dense-analysis / ale

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

Ruff always raises E474: Unidentified byte and E474: Failed to parse bash on ALELint #4714

Closed eduardosprp closed 4 months ago

eduardosprp commented 9 months ago

Information

VIM version

NVIM v0.7.2 Build type: Release

Operating System: Debian 12 "Bookworm" Ruff version: ruff 0.1.14

I couldn't find where to check ALE's version from the plugin itself or from vim-plug (which is how I installed it). But since I had run :PlugUpdate before doing anything, I suppose it's the latest version as of today 27/01/2024

What went wrong

Hello. I have been using ruff with ALE for neovim for a few months, and recently it started raising the following errors on each ALELint:

Error detected while processing function 100_NeoVimCallback[29]..48[1]..95_ExitCallback[28]..94_HandleExit[24]..ale_linters#python#ruff#Handle: line 4: E474: Unidentified byte: bash: cannot set terminal process group (-1): Inappropriate ioctl for device Press ENTER or type command to continue Error detected while processing function 100_NeoVimCallback[29]..48[1]..95_ExitCallback[28]..94_HandleExit[24]..ale_linters#python#ruff#Handle: line 4: E474: Failed to parse bash: cannot set terminal process group (-1): Inappropriate ioctl for device Press ENTER or type command to continue

Outside of neovim and ALE ruff works fine, even if I use the same commands as ALE is using (see "Reproducing the Bug" and "ALEInfo" below).

I have also tested pylint for the same files, and it is working fine with ALE.

I am only using ruff for the linter, and Black and Isort for the fixers (see ALEInfo below), and these are also not raising any errors.

Reproducing the bug

  1. Create any Python file, for instance test.py:
    print("test")
    example
  2. Run ALELint on it, get the output:
Error detected while processing function <SNR>100_NeoVimCallback[29]..<lambda>48[1]..<SNR>95_ExitCallback[28]..<SNR>94_HandleExit[24]..ale_linters#python#ruff#Handle:
line    4:
E474: Unidentified byte: bash: cannot set terminal process group (-1): Inappropriate ioctl for device
Press ENTER or type command to continue
Error detected while processing function <SNR>100_NeoVimCallback[29]..<lambda>48[1]..<SNR>95_ExitCallback[28]..<SNR>94_HandleExit[24]..ale_linters#python#ruff#Handle:
line    4:
E474: Failed to parse bash: cannot set terminal process group (-1): Inappropriate ioctl for device
Press ENTER or type command to continue
  1. To verify that ruff works outside of neovim + ALE, run the same commands from the terminal:

/bin/bash -ic 'cd ''/home/eduardo/Code/Python'' && ''ruff'' -q --output-format json-lines --stdin-filename ''/home/eduardo/Code/Python/test.py'' - < ''/tmp/nvimpSUAfY/11/test.py'''

The output is as expected:

{"cell":null,"code":"F821","end_location":{"column":8,"row":2},"filename":"/home/eduardo/Code/Python/test.py","fix":null,"location":{"column":1,"row":2},"message":"Undefined name example","noqa_row":2,"url":"https://docs.astral.sh/ruff/rules/undefined-name"}

:ALEInfo

Expand Current Filetype: python Available Linters: ['bandit', 'cspell', 'flake8', 'flakehell', 'jedils', 'mypy', 'prospector', 'pycln', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pylsp', 'pyre', 'pyright', 'refurb', 'ruff', 'unimport', 'vulture'] Linter Aliases: 'jedils' -> ['jedi_language_server'] Enabled Linters: ['ruff'] Ignored Linters: [] Suggested Fixers: 'add_blank_lines_for_python_control_statements' - Add blank lines before control statements. 'autoflake' - Fix flake issues with autoflake. 'autoimport' - Fix import issues with autoimport. 'autopep8' - Fix PEP8 issues with autopep8. 'black' - Fix PEP8 issues with black. 'isort' - Sort Python imports with isort. 'pycln' - remove unused python import statements 'pyflyby' - Tidy Python imports with pyflyby. 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'reorder-python-imports' - Sort Python imports with reorder-python-imports. 'ruff' - A python linter/fixer for Python written in Rust 'ruff_format' - Fix python files with the ruff formatter. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. 'yapf' - Fix Python files with yapf. Linter Variables: let g:ale_python_auto_pipenv = 0 let g:ale_python_auto_poetry = 0 let g:ale_python_auto_virtualenv = 0 let g:ale_python_black_options = '--line-length=79' let g:ale_python_ruff_auto_pipenv = 0 let g:ale_python_ruff_auto_poetry = 0 let g:ale_python_ruff_change_directory = 1 let g:ale_python_ruff_executable = 'ruff' let g:ale_python_ruff_options = '' let g:ale_python_ruff_use_global = 0 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_disable_lsp = 'auto' 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 = {'*': ['remove_trailing_lines', 'trim_whitespace'], 'python': ['isort', 'black']} let g:ale_history_enabled = 1 let g:ale_info_default_mode = 'preview' 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 = 0 let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'never' let g:ale_linter_aliases = {} let g:ale_linters = {'python': ['ruff']} 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_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 = v:null let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_root = {} 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_type_map = {} let g:ale_use_neovim_diagnostics_api = 1 let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 'all' let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History: (executable check - success) ruff (finished - exit code 0) ['/bin/bash', '-ic', 'cd ''/home/eduardo/Code/Python'' && ''ruff'' --version'] <<>> bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell ruff 0.1.14 <<>> (finished - exit code 1) ['/bin/bash', '-ic', 'cd ''/home/eduardo/Code/Python'' && ''ruff'' -q --output-format json-lines --stdin-filename ''/home/eduardo/Code/Python/test.py'' - < ''/tmp/nvimjnkj6O/2/test.py'''] <<>> bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell {"cell":null,"code":"F821","end_location":{"column":8,"row":2},"filename":"/home/eduardo/Code/Python/test.py","fix":null,"location":{"column":1,"row":2},"message":"Undefined name `example`","noqa_row":2,"url":"https://docs.astral.sh/ruff/rules/undefined-name"} <<>>
JonZeolla commented 7 months ago

I'm running into something similar, but only when I have a .env in the same dir as the file I'm editing, even if the .env file is empty.

w0rp commented 4 months ago

I've fixed this now. ALE will now read all line of probable JSONL output from ruff and only use the lines that are valid JSON. If any other nonsense is returned by ruff, ALE should not throw exceptions.