So I downloaded the fugitive plugin for Vim and try to get it running on my Windows 7 machine.
I don't have the path to git.exe
in my %PATH%
and I don't want to add it since issues could arise doing such.
My Git is installed at C:\Program Files (x86)\Git\
. There's a config option for fugitive where I could tell my path to git.exe
(g:fugitive_git_executable
).
I've tried several flavours:
'C:/Program Files (x86)/Git/cmd/git.exe'
'C:\Program Files (x86)\Git\cmd\git.exe'
"C:\Program Files (x86)\Git\cmd\git.exe"
"C:\\Program Files (x86)\\Git\\cmd\\git.exe"
But none is working. Seems like in 1, 2, 4, there's a problem with the brackets in the path. The resulting call of :Git status
is
C:\WINDOWS\system32\cmd.exe /c (C:\Program Files ^(x86^)\Git\cmd\git.exe status)
and the cmd window complains that "\Git\cmd\git.exe" could not be processed
(translated from German).
How do I specify the path to git.exe
so that I don't have to expand my $PATH
variable?
Or more general: when using the system
command in Vim, how do I call programs that are located under 'C:\Program Files (x86)\
?
In your vimrc, add something like the following:
if has('win32')
let $PATH .= ';' . 'C:/Program Files (x86)/Git/bin'
endif
This won't affect the value of %PATH% outside of Vim.
Alternatively, to get Fugitive to work as advertised, you'll have to patch it a bit. In s:Git() replace
call s:ExecuteInTree('!'.git.' '.cmd)
with
if has('win32')
call s:ExecuteInTree('!"'.git.' '.cmd.'"')
else
call s:ExecuteInTree('!'.git.' '.cmd)
endif
and then put quotation marks around the path to the executable in your vimrc:
let g:fugitive_git_executable = '"C:/Program Files (x86)/Git/bin/git"'
(See correct quoting for cmd.exe for multiple arguments.)
You might want to get in touch with the maintainer. I'd be surprised if this issue hasn't cropped up before.
I just modify $PATH. Some programs require $PATH to be set correctly, anyhow.
(Plus: @echristopherson's solution is perfectly viable, but it's annoying to have to resort to that in the 21st Century.)
The standard directory C:\Program Files (x86)
can be abbreviated to C:\Progra~2
*. This kind of shortened name is how long filenames or filenames with spaces in them were actually represented on FAT filesystems (which internally are restricted to filenames of eight base characters and three extension characters) from Windows 95 on, but it's still supported for compatibility in modern Windows systems using NTFS, at least in specific cases like the Program Files (x86)
folder.
C:\Program Files
is, similarly, C:\Progra~1
.
* In Vimscript the backslashes should be changed to slashes unless they are either doubled up or enclosed in single quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With