ludovicchabant / vim-gutentags

A Vim plugin that manages your tag files
https://bolt80.com/gutentags/
MIT License
2.3k stars 175 forks source link

On Windows, multiple duplicate tag files generated with increasing number of backslashes #217

Open ghost opened 5 years ago

ghost commented 5 years ago

Describe the bug On Windows 10, I have source code on A:\ drive. Opening a file with gutentags correctly generates the tag file in a tmp directory I have specified, and editing the file causes that tag file to be correctly updated. But if I attempt to use the tag file in vim (jump to definition in same file) gutentags does not use the file it generated, it generates another duplicate tag file, this time with an extra backslashes in the path. Each time I jump to definition, it regenerates the tag file with more backslashes. It does jump to the correct tab, but spits out an error relating to chdir function.

Steps to reproduce

  1. Open file on secondary drive, observe that tag file is generated correctly with no error messages in g:gutentags_cache_dir
  2. In the same file, jump to the definition of a symbol (g C-])
  3. Observe that gutentags reports that no tag file is found (but it just generated it), it regenerates a second one with extra backslash after drive letter name, then uses that to jump to definition. It reports an error regarding chdir. But it does jump to the correct definition.
  4. Do step 2 again and observe the same thing, this time with yet another backslash in generated tag name.

Share your setup

Gutentags config:

  let g:gutentags_enabled                   = 1
  let g:gutentags_trace                     = 1
  let g:gutentags_add_default_project_roots = 1
  let g:gutentags_project_root              = ['package.json']
  let g:gutentags_exclude_filetypes         = []
  let g:gutentags_exclude_project_root      = []
  let g:gutentags_generate_on_missing       = 1
  let g:gutentags_generate_on_new           = 1
  let g:gutentags_generate_on_write         = 1
  let g:gutentags_generate_on_empty_buffer  = 0
  let g:gutentags_cache_dir                 = expand(g:crf_tmp_vim_dir . '/tags')
  let g:gutentags_ctags_tagfile             = 'tags'
  let g:gutentags_ctags_auto_set_tags       = 1
  let g:gutentags_resolve_symlinks          = 0
  let g:gutentags_ctags_exclude_wildignore  = 1
  noremap [tags]u :<C-u>GutentagsUpdate<CR>
  noremap [tags]d :<C-u>GutentagsToggleEnabled<CR>
  if exists("g:plugs['lightline.vim']")
    augroup crf_vimrc
      autocmd User GutentagsUpdating call lightline#update()
      autocmd User GutentagsUpdated call lightline#update()
    augroup END
  endif

Post the logs This is the logging for step 1 above:

Locking tags file... 
Removing references to: A:\Development\pcm-app\lambdas\api\src\model\simulation.js 
findstr /V /C:"A:\Development\pcm-app\lambdas\api\src\model\simulation.js" "C:\Users\Chris\vimfiles\.tmp\tags\A--Development-pcm-app-lambdas-api-tags" > "C:\Users\Chris\vimfiles\.tmp\tags\A--Development-pcm-app-lambdas-api-tags.temp" 
Running ctags 
call "ctags" -f "C:\Users\Chris\vimfiles\.tmp\tags\A--Development-pcm-app-lambdas-api-tags.temp"  --options="C:\Users\Chris\vimfiles\.tmp\plug\vim-gutentags\res\ctags_recursive.options" --exclude="@C:\Users\Chris\vimfiles\.tmp\tags/_wildignore.options" --append "A:\Development\pcm-app\lambdas\api\src\model\simulation.js" 
Replacing tags file 
move /Y "C:\Users\Chris\vimfiles\.tmp\tags\A--Development-pcm-app-lambdas-api-tags.temp" "C:\Users\Chris\vimfiles\.tmp\tags\A--Development-pcm-app-lambdas-api-tags" 
        1 file(s) moved.
Unlocking tags file... 
Done. 

Now this is the logging for step 2 (when things go wrong):

Locking tags file... 
Running ctags 
call "ctags" -f "C:\Users\Chris\vimfiles\.tmp\tags\A---Development-pcm-app-lambdas-api-tags.temp"  --options="C:\Users\Chris\vimfiles\.tmp\plug\vim-gutentags\res\ctags_recursive.options" --exclude="@C:\Users\Chris\vimfiles\.tmp\tags/_wildignore.options" "A:\\Development\pcm-app\lambdas\api" 
Replacing tags file 
move /Y "C:\Users\Chris\vimfiles\.tmp\tags\A---Development-pcm-app-lambdas-api-tags.temp" "C:\Users\Chris\vimfiles\.tmp\tags\A---Development-pcm-app-lambdas-api-tags" 
        1 file(s) moved.
Unlocking tags file... 
Done. 

And the third time:

Locking tags file... 
Running ctags 
call "ctags" -f "C:\Users\Chris\vimfiles\.tmp\tags\A-----Development-pcm-app-lambdas-api-tags.temp"  --options="C:\Users\Chris\vimfiles\.tmp\plug\vim-gutentags\res\ctags_recursive.options" --exclude="@C:\Users\Chris\vimfiles\.tmp\tags/_wildignore.options" "A:\\\\Development\pcm-app\lambdas\api" 
Replacing tags file 
move /Y "C:\Users\Chris\vimfiles\.tmp\tags\A-----Development-pcm-app-lambdas-api-tags.temp" "C:\Users\Chris\vimfiles\.tmp\tags\A-----Development-pcm-app-lambdas-api-tags" 
        1 file(s) moved.
Unlocking tags file... 
Done. 

The chdir error is not captured in the logs, but looks like this. it spits out after trying to jump to definition, assuming it's related to the duplicate tag file problem: image

Additional context Here you can see the duplicate tag files it generates for a file located at A:\Development\pcm-app\lambdas\api\src\model\simulation.js: image

ws198601 commented 5 years ago

i have this bug, could you tell me the way to solve this bug. Thank you very much!

ghost commented 5 years ago

I don't think I ever solved it (not on Windows anymore so can't check). I believe it will work if you keep your files on C:/ drive though.