Vim-plug: PlugInstall breaks if Vim started from Git-for-Windows (MSYS2)

Created on 17 Oct 2016  路  9Comments  路  Source: junegunn/vim-plug

PlugInstall failure when vim is started from MSYS2

x vim-ruby:
    /usr/bin/bash: line 0: cd: /d: No such file or directory
    PlugClean required.

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 10 2013 14:38:33)
MS-Windows 32-bit GUI version with OLE support
Compiled by mool@tororo
Big version with GUI.  Features included (+) or not (-):
+arabic             +ex_extra           +mouseshape         +syntax
+autocmd            +extra_search       +multi_byte_ime/dyn +tag_binary
+balloon_eval       +farsi              +multi_lang         +tag_old_static
+browse             +file_in_path       -mzscheme           -tag_any_white
++builtin_terms     +find_in_path       +netbeans_intg      +tcl/dyn
+byte_offset        +float              +ole                -tgetent
+cindent            +folding            +path_extra         -termresponse
+clientserver       -footer             +perl/dyn           +textobjects
+clipboard          +gettext/dyn        +persistent_undo    +title
+cmdline_compl      -hangul_input       -postscript         +toolbar
+cmdline_hist       +iconv/dyn          +printer            +user_commands
+cmdline_info       +insert_expand      -profile            +vertsplit
+comments           +jumplist           +python/dyn         +virtualedit
+conceal            +keymap             +python3/dyn        +visual
+cryptv             +langmap            +quickfix           +visualextra
+cscope             +libcall            +reltime            +viminfo
+cursorbind         +linebreak          +rightleft          +vreplace
+cursorshape        +lispindent         +ruby/dyn           +wildignore
+dialog_con_gui     +listcmds           +scrollbind         +wildmenu
+diff               +localmap           +signs              +windows
+digraphs           -lua                +smartindent        +writebackup
-dnd                +menu               -sniff              -xfontset
-ebcdic             +mksession          +startuptime        -xim
+emacs_tags         +modify_fname       +statusline         -xterm_save
+eval               +mouse              -sun_workshop       +xpm_w32
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
  system gvimrc file: "$VIM\gvimrc"
    user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
3rd user gvimrc file: "$VIM\_gvimrc"
    system menu file: "$VIMRUNTIME\menu.vim"
Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32   -DFEAT_CSCOPE 
-DFEAT_NETBEANS_INTG   -DFEAT_XPM_W32   -DWINVER=0x0400 -D_WIN32_WINNT=0x0400  
/Fo.\ObjGOLYHTRi386/ /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME 
-DFEAT_GUI_W32 -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL 
-DDYNAMIC_TCL_DLL=\"tcl85.dll\" -DDYNAMIC_TCL_VER=\"8.5\" -DFEAT_PYTHON -DDYNAMIC_PYTHON 
-DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 
-DDYNAMIC_PYTHON3_DLL=\"python32.dll\" -DFEAT_PERL -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl51
4.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=19 -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby192.
dll\" -DFEAT_BIG /Fd.\ObjGOLYHTRi386/ /Zi
Linking: link /RELEASE /nologo /subsystem:windows /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib 
shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:i386 /nodefaultlib gdi32.lib version.lib   winspool.lib 
comctl32.lib advapi32.lib shell32.lib  /machine:i386 /nodefaultlib libcmt.lib oleaut32.lib  user32.lib      
/nodefaultlib:python27.lib /nodefaultlib:python32.lib   "E:\tcl\lib\tclstub85.lib" WSock32.lib 
xpm\x86\lib\libXpm.lib /PDB:gvim.pdb -debug

  • Type:

    • [x] Bug

    • [ ] Enhancement

    • [ ] Feature Request

    • [ ] Question

  • OS:

    • [ ] All/Other

    • [ ] Linux

    • [ ] OS X

    • [x] Windows

  • Vim:

    • [x] Terminal Vim

    • [x] GVim

    • [ ] Neovim

windows

Most helpful comment

Yeah, i'm far from an expert on Windows environment myself. When using the bash shell for windows, /usr/bin/bash IS the valid path to bash.exe. I'll post back if i run into any problems after adding this in my .vimrc.

if has('win32') || has('win64')
        let &shell='cmd.exe'
endif

The same .vimrc still seems to work with vim-plug for Windows gvim, MSYSGIT BASH vim, and WSL (windows subsystem for linux running Ubuntu) vim. And since i also have the MSYSGIT bash executable on my windows path, i believe calls to 'rm -rf' are valid everywhere in windows for me. I'm not sure how to dynamically change the &shell in vim when vim-plug loads and exits.

[tmuka@WRKSTN-C168RD2:~/vimfiles]$ echo $SHELL
/usr/bin/bash
[tmuka@WRKSTN-C168RD2:~/vimfiles]$ which bash
/usr/bin/bash
[tmuka@WRKSTN-C168RD2:~/vimfiles]$ bash --version
GNU bash, version 4.3.42(5)-release (x86_64-pc-msys)
[tmuka@WRKSTN-C168RD2:~/vimfiles]$ start ver
Microsoft Windows [Version 10.0.14393]

Hopefully this helps somebody else stuck on windows!

All 9 comments

We use cd /d on Windows since #155. Can you post the output of :echo &shell or your system? Maybe we can add /d only when it matches cmd.

I have a similar issue when running PlugInstall in vim.exe launched inside MSYSGIT (aka Windows GitBash). The error is the same when gvim.exe is launched from MSYSGIT.

'C:\Program' is not recognized as an internal or external command,
'C:\Program' is not recognized as an internal or external command,
Error detected while processing function <SNR>9_install[1]..<SNR>9_update_impl[56]..<SNR>9_git_version_requirement[2]..<SNR>9_system:
line    4:
E484: Can't open file C:/Users/myuser/AppData/Local/Temp/VIo9CBB.tmp
Error detected while processing function <SNR>9_install[1]..<SNR>9_update_impl[56]..<SNR>9_git_version_requirement:
line    2:
E171: Missing :endif
Press ENTER or type command to continue

the output of my vim :echo &shell is C:\Program Files\Git\usr\bin\bash

vim and bash versions for reference. This is Windows 10.

tmuka@WRKSTN-C168RD2:~]$ bash --version | head -n1
GNU bash, version 4.3.42(5)-release (x86_64-pc-msys)
[tmuka@WRKSTN-C168RD2:~]$ vim --version | head -n1
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 12 2016 18:17:48)

edit: I forgot to mention, :PlugInstall works fine if i start gvim from the windows start menu.

I suppose i need to figure out if i can change the shell path to not have spaces.

sorry, @go2null maybe I should have started a new issue for this.
Even if I add let &shell='/usr/bin/bash/' to .vimrc i still get a different error.

Error detected while processing function <SNR>9_install[1]..<SNR>9_update_impl[56]..<SNR>9_git_version_requirement[2]..<SNR>9_system:
line    4:
E484: Can't open file C:/Users/tmuka/AppData/Local/Temp/VIo8D10.tmp
Error detected while processing function <SNR>9_install[1]..<SNR>9_update_impl[56]..<SNR>9_git_version_requirement:
line    2:
E171: Missing :endif

It looks like a permissions problem with how it's trying to write the .tmp files.

I discovered i'm able to get it working by changing &shell in .vimrc to 'cmd.exe'. I'm not sure how that effects other things i may try to do, but it makes PlugInstall work!

"let &shell='/usr/bin/bash'
let &shell='cmd.exe'

@tmuka Thanks, I'm not an expert on Windows environment. I wonder if it makes sense for vim-plug to automatically set &shell to cmd.exe. Hmm.

let &shell='/usr/bin/bash' won't work on Windows, right? Windows doesn't have a /usr/bin directory...

If you want to use bash as your shell, that's ok as long as bash is installed on your system. Just specify the path to bash.exe, but _remember to escape spaces_. See :h 'shell'.

If vim-plug relies on the shell, you might want to set it (just remember to restore it when vim-plug exits). You can probably get by with cmd.exe and /bin/sh (although I saw some calls to rm -rf in the code that might need to be converted to something cross-platform).

Yeah, i'm far from an expert on Windows environment myself. When using the bash shell for windows, /usr/bin/bash IS the valid path to bash.exe. I'll post back if i run into any problems after adding this in my .vimrc.

if has('win32') || has('win64')
        let &shell='cmd.exe'
endif

The same .vimrc still seems to work with vim-plug for Windows gvim, MSYSGIT BASH vim, and WSL (windows subsystem for linux running Ubuntu) vim. And since i also have the MSYSGIT bash executable on my windows path, i believe calls to 'rm -rf' are valid everywhere in windows for me. I'm not sure how to dynamically change the &shell in vim when vim-plug loads and exits.

[tmuka@WRKSTN-C168RD2:~/vimfiles]$ echo $SHELL
/usr/bin/bash
[tmuka@WRKSTN-C168RD2:~/vimfiles]$ which bash
/usr/bin/bash
[tmuka@WRKSTN-C168RD2:~/vimfiles]$ bash --version
GNU bash, version 4.3.42(5)-release (x86_64-pc-msys)
[tmuka@WRKSTN-C168RD2:~/vimfiles]$ start ver
Microsoft Windows [Version 10.0.14393]

Hopefully this helps somebody else stuck on windows!

Thanks so much for the workaround @tmuka! It worked, I have plugins!

This has been bothering me for weeks. Tonight I switched from Vundle.vim to vim-plug in an attempt to fix the problem.

I am running win10, Git Bash in Hyper term with config:

     shell: "C:\\Program\ Files\\Git\\git-cmd.exe",
    shellArgs: ['--no-cd','--command=usr/bin/bash.exe', '-l','-i'],

I experience this with vim.org binaries and nightly binaries
cc https://github.com/VundleVim/Vundle.vim/issues/779

Running the native Windows vim in msys or cygwin is not recommended so it's safe to default to cmd.exe for shell and setting all shell-related options to their default values when running shell commands for vim-plug.

```viml
set shell=cmd.exe noshellslash shellquote&vim shellxquote&vim
````

Problem is Vim and Neovim have different default values for those options so porting Vim code from fzf could be necessary.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fashaun picture Fashaun  路  9Comments

airblade picture airblade  路  9Comments

jdhao picture jdhao  路  11Comments

alexanderjeurissen picture alexanderjeurissen  路  8Comments

MarcMdev picture MarcMdev  路  16Comments