Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows GVim File Path Issue #857

Closed
umitkablan opened this issue May 16, 2016 · 7 comments
Closed

Windows GVim File Path Issue #857

umitkablan opened this issue May 16, 2016 · 7 comments

Comments

@umitkablan
Copy link

Actual behavior

When run :GoMetalinter:

|| WARNING: failed to execute linter errcheck -abspath .: chdir C:UsersUmitkSRCGosrctutorialhello_world: The system cannot find the file specified.
|| WARNING: failed to execute linter golint -min_confidence 0.800000 .: chdir C:UsersUmitkSRCGosrctutorialhello_world: The system cannot find the file specified.
|| WARNING: failed to execute linter go tool vet ./*.go: chdir C:UsersUmitkSRCGosrctutorialhello_world: The system cannot find the file specified.

file seperators seems to be missing. Similar path problem occurs when you type [[ to go to the beginning of the function.

There is no problem when I :w the file where Syntastic takes place and use 'g:syntastic_go_checkers = ["go", "gofmt", "golint", "gometalinter", "govet"]' successfully.

Expected behavior

GoMetaLinter to run successfully - at least no problem with paths.

Steps to reproduce:

On a Windows platform

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 11 2016 22:07:21)
MS-Windows 64-bit GUI version with OLE support
Included patches: 1-1724
Compiled by appveyor@APPVEYOR-VM
Huge version with GUI. Features included (+) or not (-):
+acl +cmdline_compl +digraphs +float +libcall +multi_byte_ime/dyn +profile +statusline +title +windows
+arabic +cmdline_hist +directx +folding +linebreak +multi_lang +python/dyn -sun_workshop +toolbar +writebackup
+autocmd +cmdline_info -dnd -footer +lispindent +mzscheme/dyn +python3/dyn +syntax +user_commands -xfontset
+balloon_eval +comments -ebcdic +gettext/dyn +listcmds +netbeans_intg +quickfix +tag_binary +vertsplit -xim
+browse +conceal +emacs_tags -hangul_input +localmap +ole +reltime +tag_old_static +virtualedit -xterm_save
++builtin_terms +cryptv +eval +iconv/dyn +lua/dyn +packages +rightleft -tag_any_white +visual +xpm_w32
+byte_offset +cscope +ex_extra +insert_expand +menu +path_extra +ruby/dyn +tcl/dyn +visualextra
+channel +cursorbind +extra_search +job +mksession +perl/dyn +scrollbind -tgetent +viminfo
+cindent +cursorshape +farsi +jumplist +modify_fname +persistent_undo +signs -termresponse +vreplace
+clientserver +dialog_con_gui +file_in_path +keymap +mouse -postscript +smartindent +textobjects +wildignore
+clipboard +diff +find_in_path +langmap +mouseshape +printer +startuptime +timers +wildmenu
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_JOB_CHANNEL -DFEAT_XPM_W32 -DWINVER=0x500 -D_WIN32_WINNT=0x500 /Fo.\ObjGXOULYHTRZAMD64/ /Ox /GL -DNDEBUG /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_MBYTE -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL="tcl86.dll" -DDYNAMIC_TCL_VER="8.6" -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL="lua53.dll" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL="python27.dll" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL="python34.dll" -DFEAT_MZSCHEME -I "C:\Program Files\Racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL="libracket3m_9zltds.dll" -DDYNAMIC_MZGC_DLL="libracket3m_9zltds.dll" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL="perl522.dll" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=22 -DDYNAMIC_RUBY_DLL="x64-msvcrt-ruby220.dll" -DFEAT_HUGE /Fd.\ObjGXOULYHTRZAMD64/ /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:AMD64 gdi32.lib version.lib winspool.lib comctl32.lib advapi32.lib shell32.lib /machine:AMD64 /nodefaultlib libcmt.lib oleaut32.lib user32.lib /nodefaultlib:lua53.lib /STACK:8388608 /nodefaultlib:python27.lib /nodefaultlib:python34.lib "C:\Tcl\lib\tclstub86.lib" WSock32.lib xpm\x64\lib\libXpm.lib /PDB:gvim.pdb -debug

Configuration

I used ^HEAD vim-go with NeoBundle and:

let g:go_def_mapping_enabled = 1
let g:go_autodetect_gopath = 0
let g:go_snippet_engine = "neosnippet"
let g:go_list_type = "quickfix"

@fatih
Copy link
Owner

fatih commented May 16, 2016

Hi @umitkablan

This error is not coming from vim-go:

|| WARNING: failed to execute linter go tool vet ./*.go: chdir C:UsersUmitkSRCGosrctutorialhello_world: The system cannot find the file specified.

Seems like it's coming straight from gometalinter. Can you please try it a with a minimal vimrc setup, and use only vim-go without any plugins.

Thanks

@umitkablan
Copy link
Author

umitkablan commented May 17, 2016

Hi @fatih,

I suspected your generic suggestion and started digging the code and come up with a pragmatic solution for [[ movement:

diff --git a/autoload/go/textobj.vim b/autoload/go/textobj.vim
index 1901d06..e53d24e 100644
--- a/autoload/go/textobj.vim
+++ b/autoload/go/textobj.vim
@@ -116,7 +116,7 @@ function! go#textobj#FunctionJump(mode, direction)
     return
   endif

-  let command = printf("%s -format vim -file %s -offset %s", bin_path, fname, offset)
+  let command = printf("%s -format vim -file '%s' -offset %s", bin_path, fname, offset)
   let command .= ' -shift ' . l:cnt

   if a:direction == 'next'

The only difference I did was to enclose %s filepath into single quotes.

Similarly for :GoMetaLinter, I experimented such a change works without problem:

diff --git a/autoload/go/lint.vim b/autoload/go/lint.vim
index 236abb7..49fa59f 100644
--- a/autoload/go/lint.vim
+++ b/autoload/go/lint.vim
@@ -51,7 +51,7 @@ function! go#lint#Gometa(autosave, ...) abort
         let meta_command .= " --deadline=" . g:go_metalinter_deadline

         " path
-        let meta_command .=  " " . goargs
+        let meta_command .=  " '" . goargs ."'"
     else
         " the user wants something else, let us use it.
         let meta_command = g:go_metalinter_command

What do you think? As I said it is a come-up solution on windows platform without digging in vim scripting or else. Just a programmer sense :)

@fatih
Copy link
Owner

fatih commented May 18, 2016

@umitkablan I'm still not sure what the problem is. Your first issue doesn't mention anything textobj related. Can you give please more details?

@umitkablan
Copy link
Author

@fatih sorry if my question was buried in the details but I was mainly distracted by :GoMetalinter complaining about filepath cannot be located. It was clear that file path seperator (which is backslash in windows) is missing in the path. See my original question: C:UsersUmitkSRCGosrctutorialhello_worldshould be C:\Users\Umitk\SRC\Go\src\tutorial\hello_world

Simply said: plugin execs the executable with the correct path but without quotes - that it was fixed after my experimental change. I think backslash was being interpreted later during system() execution.

Similar problem was striking when [['ing - which executes a cline program (again with non-quoted current file path) and captures line number etc to move. [[ movement was also fixed after applying my experimental edit.

@fatih
Copy link
Owner

fatih commented May 18, 2016

Thanks @umitkablan, can you please test the following PR: #862 It escapes the arguments if none is passed and seems like it solves your problem. Let me know how it works for you.

@umitkablan
Copy link
Author

umitkablan commented May 20, 2016

Yes it worked @fatih, but we still need a treatment for [[ motion, like:

diff --git a/autoload/go/textobj.vim b/autoload/go/textobj.vim
index 1901d06..e53d24e 100644
--- a/autoload/go/textobj.vim
+++ b/autoload/go/textobj.vim
@@ -116,7 +116,7 @@ function! go#textobj#FunctionJump(mode, direction)
     return
   endif

-  let command = printf("%s -format vim -file %s -offset %s", bin_path, fname, offset)
+  let command = printf("%s -format vim -file '%s' -offset %s", bin_path, fname, offset)
   let command .= ' -shift ' . l:cnt

   if a:direction == 'next'

@fatih
Copy link
Owner

fatih commented May 21, 2016

Thanks @umitkablan I've also added those fixes to the motions. It's merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants