dense-analysis / dense-analysis/ale

Errors when opening fugitive.vim buffers (diff, staged, specific commit versions, etc)

Open
#4,715 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

## Information

**VIM version**

NVIM v0.9.5
Build type: Release

Operating System: macOS Sonoma 14.3

## What went wrong

When opening a fugitive.vim buffer (simplest one is doing a git diff via `:Gdiffsplit`), I'm getting errors

```
Error detected while processing function 83_NeoVimCallback[35]..function 83_NeoVimCallback[29]..59[1]..77_ExitCallbac
k[28]..76_HandleExit[24]..ale_linters#python#ruff#Handle:
line 4:
E474: Unidentified byte: /bin/sh: line 0: cd: fugitive:/Users/dmedvinsky/src/test/.git/0: No such file or directory
Press ENTER or type command to continue
Error detected while processing function 83_NeoVimCallback[35]..function 83_NeoVimCallback[29]..59[1]..77_ExitCallbac
k[28]..76_HandleExit[24]..ale_linters#python#ruff#Handle:
line 4:
E474: Failed to parse /bin/sh: line 0: cd: fugitive:/Users/dmedvinsky/src/test/.git/0: No such file or directory
```

If I set `let g:ale_python_ruff_change_directory = 0` in my config, the error goes away. But I still think this is an issue that might need fixing. Pardon me if I'm wrong about that.

## Reproducing the bug

1. Have nvim with fugitive and Ale configured to run linters like ruff (not sure if it's specific to ruff one, but looks like it affects all linters that do `cd`).
2. Create a git repo.
3. Edit an Ale-checked file in a repo.
4. Do `:Gdiffsplit`
5. Observe errors

### :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: ['jedils', 'mypy', '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_jedils_auto_pipenv = 0
let g:ale_python_jedils_executable = 'jedi-language-server'
let g:ale_python_jedils_use_global = 0
let g:ale_python_mypy_auto_pipenv = 0
let g:ale_python_mypy_auto_poetry = 0
let g:ale_python_mypy_executable = 'mypy'
let g:ale_python_mypy_ignore_invalid_syntax = 1
let g:ale_python_mypy_options = ''
let g:ale_python_mypy_show_notes = 1
let g:ale_python_mypy_use_global = 0
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_format_auto_pipenv = 0
let g:ale_python_ruff_format_auto_poetry = 0
let g:ale_python_ruff_format_change_directory = 1
let g:ale_python_ruff_format_executable = 'ruff'
let g:ale_python_ruff_format_options = ''
let g:ale_python_ruff_format_use_global = 0
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 = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
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 = 1
let g:ale_fixers = {'*': ['remove_trailing_lines', 'trim_whitespace'], 'python': ['ruff', 'ruff_format']}
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 = 0
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 = {'python': ['ruff', 'mypy', 'jedils']}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
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 = 0
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 = 1
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:

(started) ['/bin/sh', '-c', '''/Users/dmedvinsky/src/mel/.direnv/python-3.10/bin/jedi-language-server''']
(finished - exit code 1) ['/bin/sh', '-c', 'cd ''fugitive:/Users/dmedvinsky/src/mel/.git/0/dotcom/src/django/apps/accounts/forms'' && ''/Users/dmedvinsky/src/mel/.direnv/python-3.10/bin/mypy'' --show-column-numbers --shadow-file ''fugitive:///Users/dmedvinsky/src/mel/.git//0/dotcom/src/django/apps/accounts/forms/profile_signup.py'' ''/var/folders/rd/p7b3tb9j3659b5wklgs64znw0000gn/T/nvim.dmedvinsky/9mBsQL/372/profile_signup.py'' ''fugitive:///Users/dmedvinsky/src/mel/.git//0/dotcom/src/django/apps/accounts/forms/profile_signup.py''']

<<>>
/bin/sh: line 0: cd: fugitive:/Users/dmedvinsky/src/mel/.git/0/dotcom/src/django/apps/accounts/forms: No such file or directory
<<>>

(finished - exit code 1) ['/bin/sh', '-c', 'cd ''fugitive:/Users/dmedvinsky/src/mel/.git/0/dotcom/src/django/apps/accounts/forms'' && ''/Users/dmedvinsky/src/mel/.direnv/python-3.10/bin/ruff'' -q --output-format json-lines --stdin-filename ''fugitive:///Users/dmedvinsky/src/mel/.git//0/dotcom/src/django/apps/accounts/forms/profile_signup.py'' - < ''/var/folders/rd/p7b3tb9j3659b5wklgs64znw0000gn/T/nvim.dmedvinsky/9mBsQL/373/profile_signup.py''']

<<>>
/bin/sh: line 0: cd: fugitive:/Users/dmedvinsky/src/mel/.git/0/dotcom/src/django/apps/accounts/forms: No such file or directory
<<>>

```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing :Gdiffsplit with ALE, fugitive and Ruff on a Python file in a Git repository. Read ale_linters#python#ruff#Handle and compare the :ALEInfo command history for Ruff and mypy, which both attempt to cd into fugitive: paths. Done means opening fugitive buffers no longer produces the reported directory or parsing errors without disabling g:ale_python_ruff_change_directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, neovim, python, shell, vim
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.