Coder Social home page Coder Social logo

Comments (10)

airblade avatar airblade commented on May 20, 2024 1

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.

BaktashGorgani avatar BaktashGorgani commented on May 20, 2024

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.

airblade avatar airblade commented on May 20, 2024

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.

BaktashGorgani avatar BaktashGorgani commented on May 20, 2024

@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.

BaktashGorgani avatar BaktashGorgani commented on May 20, 2024

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.

airblade avatar airblade commented on May 20, 2024

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.

BaktashGorgani avatar BaktashGorgani commented on May 20, 2024

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.

airblade avatar airblade commented on May 20, 2024

The trace points to the mkdir() call in this code:

" The file we are writing to is a temporary file. Sometimes the parent
" directory is deleted outside Vim but, because Vim caches the directory
" name at startup and does not check for its existence subsequently, Vim
" does not realise. This causes E482 errors.
try
call writefile(bufcontents, a:file, 'b')
catch /E482/
call mkdir(fnamemodify(a:file, ':h'), '', '0700')
call writefile(bufcontents, a:file, 'b')
endtry

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.

airblade avatar airblade commented on May 20, 2024

Have you had a chance to test this?

from vim-gitgutter.

airblade avatar airblade commented on May 20, 2024

Closing because it's gone quiet.

from vim-gitgutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.