Vim-go: go run: no go files listed (With simple repro instructions)

Created on 5 Nov 2017  路  4Comments  路  Source: fatih/vim-go

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

In new directory (~/tmp/testcase) created src/pkg1. export GOPATH=/Users/mflower/tmp/testcase
Then created file src/pkg1/main.go:

package main

import (
    "fmt"
)

func main() {
    fmt.Println("pkg1")
}

Then edited the file with nvim src/pkg1/main.go. From normal mode typed :GoRun

What did you expect to happen?

A new window should have popped up with:

[Process exited 0]

What happened instead?

A new window popped up with

go run: no go files listed

[Process exited 1]

Configuration (MUST fill this out):

  • Vim version (first two lines from :version):

NVIM v0.2.0
Build type: Release

  • Go version (go version):

go version go1.9.2 darwin/amd64

  • Go environment (go env):

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mflower/tmp/testcase"
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/h3/5n3r3cjn2331bkjp7bjmd8jh0000gn/T/go-build216437022=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

  • vim-go version:

~/.vim/plugged/vim-go$ git rev-parse HEAD
ba6ce99a67de584e30577f17ba0f92254d0d16f6

  • vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):
call plug#begin('~/.vim/plugged')

Plug 'fatih/vim-go'                                          " Go language support

call plug#end()

Other Notes

Works fine when I use :GoRun /Users/mflower/tmp/testcase/src/pkg1/main.go

Also worked fine when I used vim8:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 5 2016 14:36:19)
MacOS X (unix) version
Included patches: 1-124

Changing into the src/pkg1 directory and running nvim main.go makes no difference. :pwd of either place makes no difference.

Running :GoPath returns /Users/mflower/tmp/testcase.

My .config/nvim/init.vim contains:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc

Most helpful comment

Ah, right. Do you know which setting it was? Just curious about that. :-)

All 4 comments

Did you save your file before typing :GoRun?

I did. In fact I just redid the repro just to make sure.

I have uncovered the problem. There was something in a file sourced in my .bashrc that didn't seem to be compatible with go#tool#ExecuteInDir. After some debugging I discovered that removing this file (which I no longer was using anyhow) seemed to fix the problem.

Ah, right. Do you know which setting it was? Just curious about that. :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smontazeran picture smontazeran  路  4Comments

SirmaXX picture SirmaXX  路  3Comments

andrejvanderzee picture andrejvanderzee  路  3Comments

orlangure picture orlangure  路  3Comments

surest picture surest  路  3Comments