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

mingw: Incompatible with mingw64 #3447

Open
bmccord2 opened this issue Aug 30, 2022 · 9 comments
Open

mingw: Incompatible with mingw64 #3447

bmccord2 opened this issue Aug 30, 2022 · 9 comments

Comments

@bmccord2
Copy link

bmccord2 commented Aug 30, 2022

What did you do? (required: The issue will be closed when not provided)

Ran plugin with mingw64 (git bash for windows). I believe this problem likely would affect msys2 as well.

What did you expect to happen?

What happened instead?

When opening a file paths are not properly formed in plugin. I get a message like:
vim-go: failed to load view for file:///C:/c/path/to/my/project: invalid workspace folder path: The system cannot find the path specified.; check that the casing of the configured workspace folder path agrees with the casing reported by the operating system

Looked into the code a little bit, has('Win32') is used by the IsWin function in util.vim. This returns 0 for msys2/mingw64. has('Win32unix') returns 1 as does has('unix').

Also, GoInstallBinaries did not work without explicitly setting GOBIN variable as GOPATH/bin (not sure if this is related or not, I no longer have the error messages, but they complained about GOBIN).

Configuration (MUST fill this out):

vim-go version:

4d6962d

vimrc you used to reproduce:

vimrc
set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"call vundle#begin('~/some/path/here')

Plugin 'VundleVim/Vundle.vim'


Plugin 'heavenshell/vim-pydocstring'
Plugin 'wannesm/wmgraphviz.vim'
Plugin 'vim-scripts/reload.vim'
Plugin 'vim-scripts/vim-misc'
Plugin 'romainl/Apprentice'
Plugin 'iamcco/markdown-preview.nvim'
Plugin 'fatih/vim-go'



call vundle#end()            " required
filetype plugin indent on    " required
"filetype plugin on

colorscheme default

if &diff
    colorscheme molokai
endif

:set tabstop=4
:set shiftwidth=4
:set softtabstop=4
:set expandtab
:set autoindent

augroup myvimrchooks
    au!
    autocmd bufwritepost .vimrc source ~/.vimrc
augroup END

filetype plugin on

autocmd FileType yaml setlocal shiftwidth=2 tabstop=2 softtabstop=2

nmap <silent> <c-p> <Plug>(pydocstring)

nnoremap <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>

Vim version (first three lines from :version):

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Nov 22 2021 19:31:05)
Included patches: 1-3582
Compiled by <https://www.msys2.org/>

Go version (go version):

go version go1.19 windows/amd64

Go environment

go env Output:
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\bmccord\AppData\Local\go-build
set GOENV=C:\Users\bmccord\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\bmccord\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:/Users/bmccord/go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.19
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\bmccord\AppData\Local\Temp\go-build3966281748=/tmp/go-build -gno-record-gcc-switches

gopls version

gopls version Output:
golang.org/x/tools/gopls v0.9.4
    golang.org/x/tools/[email protected] h1:YhHOxVi++ILnY+QnH9FGtRKZZrunSaR7OW8/dCp7bBk=
@bhcleek
Copy link
Collaborator

bhcleek commented Sep 2, 2022

Vim-go is unlikely to support mingw64 explicitly; I don't have a Windows machine to test with, and arguably one would be better off using Vim built for Windows than trying to use one built specifically for mingw64.

@bhcleek
Copy link
Collaborator

bhcleek commented Jan 19, 2023

I think the error message you're seeing is actually coming from gopls and is merely being surfaced by vim-go. I'm not sure if there's anything that vim-go can do about this. I wonder if this would resolve itself if you configured your environment to use the mingw64 version of Go and then rebuilt the binaries that vim-go needs using :GoUpdateBinaries.

@CosmicSpaceGoose
Copy link

CosmicSpaceGoose commented Feb 23, 2023

mingw64 doesn't provide golang package because it is the same windows version. Last time I tried to figure out root cause it was a problem with a path notations: / vs \. But using same binaries from shell itself worked fine.

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 23, 2023

Yes, the problems is paths, but the systems ability to understand a path will depend on how it was compiled. In this case, it looks like gopls was compiled outside of mingw, but is being used inside of mingw. Running vim in mingw and executing :GoUpdateBinaries gopls may resolve this.

@CosmicSpaceGoose
Copy link

Yes, the problems is paths, but the systems ability to understand a path will depend on how it was compiled. In this case, it looks like gopls was compiled outside of mingw, but is being used inside of mingw. Running vim in mingw and executing :GoUpdateBinaries gopls may resolve this.

Nope. Same error as at issue description.

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 26, 2023

I'm not sure how to solve this. The problem is the the path has /C:/c where it should just be /c. I think this may be a consequence of effectively trying to use a binaries in the mingw context that are compiled without using mingw, but I'm not sure, and I don't have a way to test.

It may be related to the Go version that's being used, or something else. Until we can find a solution, I'd recommend not using mingw's Vim on Windows with vim-go.

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 26, 2023

Maybe we can get to the bottom of this. Here's what I need:

  1. execute let g:go_debug=['lsp'] and reproduce the problem. I need the contents of the __GOLSP_LOG__ window.
  2. What does :echo expand('%:p:h') output for you?
  3. What does :echo expand('%:p') output for you?
  4. What does :echo resolve('%:p:h) output for you?
  5. What does :cd expand('%:p:h) | !go env GOMOD output for you?

@CosmicSpaceGoose
Copy link

CosmicSpaceGoose commented Mar 1, 2023

I'd recommend not using mingw's Vim on Windows with vim-go.

Idea is to use vim within a shell. So, I'm not using vim-go :D

execute ..

File: D:\main.go

  1. let g:go_debug=['lsp']
===== sent =====
Content-Length: 227

{"method":"textDocument/didChange","jsonrpc":"2.0","params":{"contentChanges":[{"text":"package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n}\n"}],"textDocument":{"uri":"file:///d/main.go","version":5}}}
  1. echo expand('%:p:h')
/d
  1. echo expand('%:p')
/d/main.go
  1. echo resolve('%:p:h); mistake in the command, do You want echo resolve(expand('%:p:h')) ? Here it is
/d
  1. cd expand('%:p:h') | !go env GOMOD
E344: Can't find directory "expand('/d')" in cdpath
E472: Command failed
Press ENTER or type command to continue

@bmccord2
Copy link
Author

bmccord2 commented Mar 6, 2023

Hey sorry I haven't been active in this thread--I actually forgot I posted this issue. I ended up using VS Code for the golang development I needed to do and am not actively using golang at this time so I don't have much to offer in terms of debugging unfortunately

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

3 participants