ludovicchabant/vim-gutentags

cdpath can't find directory which has space.

roachsinai opened this issue · 10 comments

Describe the bug

Got error when use Vim open file which is located at directory that has space in directory name.

Error

处理 function gutentags#setup_gutentags[101]..<SNR>107_update_tags[42]..gutentags#chdir 时发生错误:
第    6 行:
E344: cdpath 中找不到目录 "/home/roach/Nutstore\ Files/我的坚果云"
E472: 命令执行失败
E344: cdpath 中找不到目录 "/home/roach/Nutstore\ Files/我的坚果云"

which means cdpath can't find directory "/home/roach/Nutstore\ Files/我的坚果云"

Share your setup

  • Manjaro Linux, VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 8 2020 23:37:13)
  • local/global 6.6.4-1
  • g:gutentags_cache_dir: ~/.cache/tags

Post the logs

mess:

处理 function <SNR>107_write_triggered_update_tags[3]..<SNR>107_update_tags[42]..gutentags#chdir 时发生错误:
第    6 行:
E344: cdpath 中找不到目录 "/home/roach/Nutstore\ Files/我的坚果云"
E472: 命令执行失败
gutentags: Wildignore options file is up to date.
gutentags: Running: ['/home/roach/.vim/plugged/vim-gutentags/plat/unix/update_tags.sh', '-e', 'ctags', '-t', '/home/roach/.cache/tags/home-roach-Nutstore_Files-我的坚果云-.tags', '-p', '/home
/roach/Nutstore Files/我的坚果云', '-s', '/home/roach/Nutstore Files/我的坚果云/.cheat/vim.plugin.ale', '-o', '/home/roach/.vim/plugged/vim-gutentags/res/ctags_recursive.options', '-O', '--fi
elds=+niazS', '-O', '--extra=+q', '-O', '--c++-kinds=+px', '-O', '--c-kinds=+px', '-O', '--output-format=e-ctags', '-l', '/home/roach/.cache/tags/home-roach-Nutstore_Files-我的坚果云-.tags.lo
g']
gutentags: In:      /home/roach/code/Git/dotfiles
E344: cdpath 中找不到目录 "/home/roach/Nutstore\ Files/我的坚果云"
E472: 命令执行失败
gutentags: Running: ['gtags', '--incremental', '/home/roach/.cache/tags/home-roach-Nutstore_Files-我的坚果云']
gutentags: In:      /home/roach/code/Git/dotfiles
gutentags: Finished gtags_cscope job.

Maybe same reason with #193

Just had this yesterday for me too.
Started when I went to use vim and/or MacVim remotely but it was around the same time i updated my plugins on both my local and remote machine as well as my version of MacVim (tweak released yesterday from Homebrew).
Screenshot 2020-05-17 17 44 44

Happening over scp, with sshfs drives, just logging in over ssh to use the remote vim and just running vim locally with projects.
Screenshot 2020-05-17 17 53 30

Here's my vim version output:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 17 2020 03:53:52)
macOS version
Included patches: 1-539
Compiled by Homebrew
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       +tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
+balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +fullscreen        +num64             +textobjects
+browse            -gettext           +odbeditor         +textprop
++builtin_terms    -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     +perl              +toolbar
+cindent           +job               +persistent_undo   +transparency
+clientserver      +jumplist          +popupwin          +user_commands
+clipboard         +keymap            +postscript        +vartabs
+cmdline_compl     +lambda            +printer           +vertsplit
+cmdline_hist      +langmap           +profile           +virtualedit
+cmdline_info      +libcall           -python            +visual
+comments          +linebreak         +python3           +visualextra
+conceal           +lispindent        +quickfix          +viminfo
+cryptv            +listcmds          +reltime           +vreplace
+cscope            +localmap          +rightleft         +wildignore
+cursorbind        +lua               +ruby              +wildmenu
+cursorshape       +menu              +scrollbind        +windows
+dialog_con_gui    +mksession         +signs             +writebackup
+diff              +modify_fname      +smartindent       -X11
+digraphs          +mouse             -sound             -xfontset
+dnd               +mouseshape        +spell             +xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        -mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary        
-farsi             -mouse_sysmouse    -tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl  -L/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/config-3.8-darwin -lpython3.8 -lintl -framework CoreFoundation -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -lruby.2.7

I'm getting the same issue since plugin upgrade:

Error detected while processing function gutentags#setup_gutentags[101]..<SNR>134_update_tags[42]..gutentags#chdir:
line    6:
E344: Can't find directory "/e/dev/MQL4/Shared\ Projects" in cdpath
E472: Command failed
Error detected while processing function gutentags#setup_gutentags[101]..<SNR>134_update_tags[54]..gutentags#chdir:
line    6:
E344: Can't find directory "/e/dev/MQL4/Shared\ Projects" in cdpath
E472: Command failed
Error detected while processing function gutentags#setup_gutentags:
line  101:
E171: Missing :endif
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 27 2020 12:36:15)
Included patches: 1-460
Modified by jonathon.fernyhough@york.ac.uk
Compiled by jonathon.fernyhough@york.ac.uk
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_old_static
+arabic            +file_in_path      +mouse_urxvt       -tag_any_white
+autocmd           +find_in_path      +mouse_xterm       +tcl
+autochdir         +float             +multi_byte        +termguicolors
-autoservername    +folding           +multi_lang        +terminal
-balloon_eval      -footer            -mzscheme          +terminfo
+balloon_eval_term +fork()            +netbeans_intg     +termresponse
-browse            +gettext           +num64             +textobjects
++builtin_terms    -hangul_input      +packages          +textprop
+byte_offset       +iconv             +path_extra        +timers
+channel           +insert_expand     +perl              +title
+cindent           +job               +persistent_undo   -toolbar
-clientserver      +jumplist          +popupwin          +user_commands
-clipboard         +keymap            +postscript        +vartabs
+cmdline_compl     +lambda            +printer           +vertsplit
+cmdline_hist      +langmap           +profile           +virtualedit
+cmdline_info      +libcall           -python            +visual
+comments          +linebreak         +python3           +visualextra
+conceal           +lispindent        +quickfix          +viminfo
+cryptv            +listcmds          +reltime           +vreplace
+cscope            +localmap          +rightleft         +wildignore
+cursorbind        +lua               +ruby              +wildmenu
+cursorshape       +menu              +scrollbind        +windows
+dialog_con        +mksession         +signs             +writebackup
+diff              +modify_fname      +smartindent       -X11
+digraphs          +mouse             +sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        +mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-qOazsc/vim-8.2.0460=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lcanberra -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm
dkav commented

I am having the same problem as noted above. For me, the issue only occurs when there is a space in the path. I believe it is caused by the fnameescape command in 29de36f.

I am having the same problem as noted above. For me, the issue only occurs when there is a space in the path. I believe it is caused by the fnameescape command in 29de36f.

Yeah, it does seem to be related to spaces in the file path passed to fnameescape(). If you look at my first screenshot you'll see the result of running this on (what I assumed would be) a space-escaped file path. This was just me trying to recreate the same issue encountered at the given line of code that the error returned.

Seeing that I also get similar errors with Nerdtree has me wondering if this is not a vim issue though. vim/vim@5d98dc2#diff-18fed467ce20dda01ceb355a223a2e66

I am having the same problem as noted above. For me, the issue only occurs when there is a space in the path. I believe it is caused by the fnameescape command in 29de36f.

@dkav Did your patch solve the issue with file path spaces in your case?

I wonder if @skywind3000 added that extra escape in 29de36f in response to a particular issue. If not then there should be no reason to wait before removing it from this plugin.

Separately, do we know why it's an issue...like is fnameescape() being called too many times on a:path? Presumably it should be an idempotent operation (safely repeatable) to avoid issues like this but I'd have to reread the implementation more carefully to confirm that.
I dug down the call stack from fnameescape() in vim (git blame) and not much seems to have changed there recently that would have brought this up now.

dkav commented

@darwingr the patch solved my issue. FYI this is not the first time that this issue occurred - see issue #259. Also, I think @skywind3000 made the change in part in response to the reverted commit - see 31c0ead.

@darwingr the patch solved my issue too.

I have experienced the same. I have to check out 31c0ead and use it for now. I haven't tried @darwingr 's patch yet.

Thank you @dkav , @pnetherwood and @flipjs .
It appears we're all on some Unix-y OS with same sort of file paths.

@skywind3000 can we please get your breakdown of the situation on this? There seems to be a need for the change for proper windows file path escaping. Is that the case with you? I'd hate to have this creep back up in a few months.

Until this is sorted, out others having this issue under vim-plug can use:
Plug 'ludovicchabant/vim-gutentags', { 'commit': '31c0ead' }, reload, then :PlugInstall! vim-gutentags. That will keep you on ludovicchabant's fix.