Comments (10)
Thanks for digging into that. Adding quotation marks seems like a good idea, though with Windows you never know. I'll try to patch it over the next few days.
from vim-gitgutter.
Let me also add this is only happening when I am on Windows. On Ubuntu and Fedora it seems to run fine.
The plugin still works but this just shows up whenever I open a file.
from vim-gitgutter.
Please could you turn on logging (let g:gitgutter_log=1
), reproduce the error, then look in the log file for the command it ran? If you run that command by hand on the terminal, does it work?
from vim-gitgutter.
@airblade thanks so much for responding!
So this helped me figure out what the issue is, just not too sure how you can go about solving it.
From the gitgutter.log I can see the commands that are run and the one that fails looks like this
cd "C:\Users\bgorgani\Dev\Arris_LC\modules" && (git --no-pager show --textconv :modules/arris_cmts.py > C:\Users\bgorgani\AppData\Local\Temp\nvim.0\lRIDJR\0.4.1.py || exit 0) && (git --no-pager diff --no-ext-diff --no-color -U0 -- C:\Users\bgorgani\AppData\Local\Temp\nvim.0\lRIDJR\0.4.1.py C:\Users\bgorgani\AppData\Local\Temp\nvim.0\lRIDJR\1.4.1.py | grep "^@@ " || exit 0)
With the error message that I get back looking like this
error: Could not access 'C:UsersbgorganiAppDataLocalTempnvim.0lRIDJR0.4.1.py'
When I saw the slashes were missing from the path I knew it was because I was using Git Bash (MinGW64) and how it doesn't always play nicely with windows paths.
When I tried running Neovim again from powershell, the error did not come back.
As I said, the plugin still seems to function properly but you just get the error message when you open any file.
Here is a comparison of the log when neovim is run from Git Bash and Powershell
Git Bash
$cat gitgutter.log
========== start log session 11.01.2024 18:32:53 ==========
0.002237 BufEnter Autocommands for "*"..function <SNR>5_on_bufenter[24]..gitgutter#process_buffer[14]..<SNR>55_setup_path[3]..gitgutter#utility#set_repo_path[15]..gitgutter#async#execute[1]:
0.002237 [async] cd "C:\Users\bgorgani\Dev\Arris_LC\modules" && git ls-files -v --error-unmatch --full-name -z -- arris_cmts.py
0.207275 function <SNR>8_on_exit_nvim[2]..1[10]..gitgutter#process_buffer[23]..gitgutter#diff#run_diff[55]..gitgutter#utility#base_path[31]..<SNR>6_obtain_file_renames[3]..gitgutter#utility#git_supports_command_line_config_override[2]..gitgutter#utility#system[1]:
0.207275 git -c foo.bar=baz --version
0.441456 function <SNR>8_on_exit_nvim[2]..1[10]..gitgutter#process_buffer[23]..gitgutter#diff#run_diff[55]..gitgutter#utility#base_path[31]..<SNR>6_obtain_file_renames[7]..gitgutter#utility#system[1]:
0.441456 cd "C:\Users\bgorgani\Dev\Arris_LC\modules" && git diff --diff-filter=R --name-status
0.660061 function <SNR>8_on_exit_nvim[2]..1[10]..gitgutter#process_buffer[23]..gitgutter#diff#run_diff[87]..gitgutter#async#execute[1]:
0.660061 [async] cd "C:\Users\bgorgani\Dev\Arris_LC\modules" && (git --no-pager show --textconv :modules/arris_cmts.py > C:\Users\bgorgani\AppData\Local\Temp\nvim.0\lRIDJR\0.4.1.py || exit 0) && (git --no-pager diff --no-ext-diff --no-color -U0 -- C:\Users\bgorgani\AppData\Local\Temp\nvim.0\lRIDJR\0.4.1.py C:\Users\bgorgani\AppData\Local\Temp\nvim.0\lRIDJR\1.4.1.py | grep "^@@ " || exit 0)
0.947186 function <SNR>8_on_exit_nvim[2]..gitgutter#diff#handler[1]:
0.947186
Powershell
$cat gitgutter.log
========== start log session 11.01.2024 18:44:39 ==========
0.002287 BufEnter Autocommands for "*"..function <SNR>5_on_bufenter[24]..gitgutter#process_buffer[14]..<SNR>55_setup_path[3]..gitgutter#utility#set_repo_path[15]..gitgutter#async#execute[1]:
0.002287 [async] cd /d "C:\Users\bgorgani\Dev\Arris_LC\modules" && git ls-files -v --error-unmatch --full-name -z -- arris_cmts.py
0.317865 function <SNR>8_on_exit_nvim[2]..1[10]..gitgutter#process_buffer[23]..gitgutter#diff#run_diff[55]..gitgutter#utility#base_path[31]..<SNR>6_obtain_file_renames[3]..gitgutter#utility#git_supports_command_line_config_override[2]..gitgutter#utility#system[1]:
0.317865 git -c foo.bar=baz --version
0.583942 function <SNR>8_on_exit_nvim[2]..1[10]..gitgutter#process_buffer[23]..gitgutter#diff#run_diff[55]..gitgutter#utility#base_path[31]..<SNR>6_obtain_file_renames[7]..gitgutter#utility#system[1]:
0.583942 cd /d "C:\Users\bgorgani\Dev\Arris_LC\modules" && git -c "core.safecrlf=false" diff --diff-filter=R --name-status
0.858046 function <SNR>8_on_exit_nvim[2]..1[10]..gitgutter#process_buffer[23]..gitgutter#diff#run_diff[87]..gitgutter#async#execute[1]:
0.858046 [async] cd /d "C:\Users\bgorgani\Dev\Arris_LC\modules" && (git --no-pager show --textconv :modules/arris_cmts.py > C:\Users\bgorgani\AppData\Local\Temp\nvim.0\92xRDg\1.4.1.py || exit 0) && (git --no-pager -c "diff.autorefreshindex=0" -c "diff.noprefix=false" -c "core.safecrlf=false" diff --no-ext-diff --no-color -U0 -- C:\Users\bgorgani\AppData\Local\Temp\nvim.0\92xRDg\1.4.1.py C:\Users\bgorgani\AppData\Local\Temp\nvim.0\92xRDg\2.4.1.py || exit 0)
1.183877 function <SNR>8_on_exit_nvim[2]..gitgutter#diff#handler[1]:
1.183877
from vim-gitgutter.
wrapping all paths in quotes seems to allow the command to run
$cd "C:\Users\bgorgani\Dev\Arris_LC\modules" && (git --no-pager show --textconv :modules/arris_cmts.py > "C:\Users\bgorgani\AppData\Local\Temp\nvim.0\GJRL21\0.4.1.py" || exit 0) && (git --no-pager diff --no-ext-diff --no-color -U0 -- "C:\Users\bgorgani\AppData\Local\Temp\nvim.0\GJRL21\0.4.1.py" "C:\Users\bgorgani\AppData\Local\Temp\nvim.0\GJRL21\1.4.1.py" | grep "^@@ " || exit 0)
warning: in the working copy of 'C:/Users/bgorgani/AppData/Local/Temp/nvim.0/GJRL21/0.4.1.py', LF will be replaced by CRLF the next time Git touches it
from vim-gitgutter.
Please could you try this on Git Bash (MinGW64), as well as Powershell, Ubuntu, and Fedora?
diff --git i/autoload/gitgutter/diff.vim w/autoload/gitgutter/diff.vim
index 6325ca3..35de9ba 100644
--- i/autoload/gitgutter/diff.vim
+++ w/autoload/gitgutter/diff.vim
@@ -97,6 +97,8 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
let buff_file .= '.'.extension
endif
+ let buff_file = gitgutter#utility#shellescape(buff_file)
+
" Write buffer to temporary file.
" Note: this is synchronous.
call s:write_buffer(a:bufnr, buff_file)
@@ -114,6 +116,8 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
let from_file .= '.'.extension
endif
+ let from_file = gitgutter#utility#shellescape(from_file)
+
" Write file from index to temporary file.
let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#base_path(a:bufnr)
let cmd .= gitgutter#git().' --no-pager show --textconv '.index_name.' > '.from_file.' || exit 0) && ('
from vim-gitgutter.
I made those 2 changes for nvim on Git Bash and, well, I am getting a different error this time and suspecting gitgutter isn't the cause of it.
This is the error I am receiving now
Error detected while processing function <SNR>28_on_exit_nvim[2]..1[10]..gitgutter#process_buffer[31]..function <SNR>28_on_exit_nvim[2]..1[10]..gitgutter#process_buffer[23]..gitgutter#diff#run_diff[41]..<SNR>88_write_buffer:
line 40:
E739: Cannot create directory "C:\Users\bgorgani\AppData\Local\Temp\nvim.0\QBixCn: invalid argument
from vim-gitgutter.
The trace points to the mkdir()
call in this code:
vim-gitgutter/autoload/gitgutter/diff.vim
Lines 404 to 413 in 67ef116
I don't know if the problem is escaping backslashes on Git Bash or some difficulty with the temp directory area.
What happens if you run it by hand, i.e. :call mkdir("C:\Users\bgorgani\AppData\Local\Temp\nvim.0\QBixCn", '', '0700')
(assuming nvim.0
exists)?
Does it work with vim (instead of nvim) on Git Bash?
from vim-gitgutter.
Have you had a chance to test this?
from vim-gitgutter.
Closing because it's gone quiet.
from vim-gitgutter.
Related Issues (20)
- b:gitgutter_was_enabled error anytime you run `saveas newfile.txt` HOT 1
- Undefined variable: b:source_window when staging from a floating preview menu HOT 2
- g:gitgutter_close_preview_on_escape is broken when exists('*nvim_open_win') HOT 2
- vim-gitgutter clobbers v:shell_error via autocmd ShellCmdPost HOT 7
- File renames aren't handled properly HOT 13
- Error detected while processing CursorHold HOT 14
- g:gitgutter_diff_base () is invalid HOT 4
- Neovim Nightly Issue HOT 2
- Neovim now prefers extmarks to signs HOT 3
- errors when file path includes colons HOT 3
- Performance issues after base_path fix HOT 5
- Branch rename breaking installations? HOT 1
- Performance issues with big files in the repository HOT 3
- cursorline highlighting doesn't work with gitgutter HOT 3
- gutter colors not showing change on correct line HOT 1
- No hunks (file possibly recognized as binary file) HOT 5
- GitGutterLineHighlightsToggle doesn't update immediately on neovim HOT 3
- GG doesn't show file changes when in a worktree HOT 3
- key map expr needs more backslashes? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-gitgutter.