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

"vim-go: goimports does not support srcdir" and file clearing #775

Closed
velovix opened this issue Mar 25, 2016 · 7 comments
Closed

"vim-go: goimports does not support srcdir" and file clearing #775

velovix opened this issue Mar 25, 2016 · 7 comments

Comments

@velovix
Copy link
Contributor

velovix commented Mar 25, 2016

Actual behavior

When GoImports is set to run when the file is saved (or perhaps more accurately, when GoFmt is run), vim-go complains with the following: "vim-go: goimports does not support srcdir." and the file is cleared and overwritten.

I have run :GoUpdateBinaries, but the problem persists.

Expected behavior

GoImports would function normally without the error message, or at least not clear the file when it fails.

Steps to reproduce:

  1. Add let g:go_fmt_command = "goimports" to your .vimrc so that GoImports is triggered on save.
  2. Open any Go file
  3. Run :w

Configuration

  • vimrc you used to reproduce
syntax on
call pathogen#infect()
call pathogen#helptags()

" vim-go configuration
let g:go_fmt_command = "goimports"
  • vim version: 7.4
  • vim-go version: tip
  • go version: go1.6 linux/amd64
@fatih
Copy link
Owner

fatih commented Mar 25, 2016

Hi @velovix

What happens if you run goimports --help from the terminal? I think it seems like you still have the old one. In the flags you should see the -srcdir flag, if that is not the case, you still have the old one.

@velovix
Copy link
Contributor Author

velovix commented Mar 25, 2016

Results of goimports --help:

$ goimports --help
usage: goimports [flags] [path ...]
  -d    display diffs instead of rewriting files
  -e    report all errors (not just the first 10 on different lines)
  -l    list files whose formatting differs from goimport's
  -srcdir dir
        choose imports as if source code is from dir
  -w    write result to (source) file instead of stdout

It looks like I'm up to date.

@fatih
Copy link
Owner

fatih commented Mar 25, 2016

What gives this ex command when you execute it from inside vim:

:echo system("goimports --help")
:echo system("which goimports")

And from your terminal:

which goimports

Seems like your Vim picks up an old version somehow. This is not something I can reproduce, let's see if we can find something.

@velovix
Copy link
Contributor Author

velovix commented Mar 26, 2016

It looks like this wasn't an issue with vim-go after all. I found that any echo system() command would print nothing, so after some messing around, I decided to reinstall vim and now everything seems to be working fine again. I have no idea what happened, but I suspect that while I was experimenting with neovim, I must have messed up something. I can't seem to reproduce it, though. Thanks for working this through with me and sorry for the noise!

@velovix velovix closed this as completed Mar 26, 2016
@leakingtapan
Copy link

leakingtapan commented Jul 3, 2016

I just had the same issue and was able to reproduce it. The symptom happens when I am using tmux.
OS: mac os x El Capitan

@tpudlik
Copy link

tpudlik commented Jul 9, 2016

I ran into this problem, too. My issue was apparently that $GOPATH/bin was not in PATH. (How vim-go managed to find a version of goimport, however outdated, I'm not sure.) Once I set export PATH=$PATH:$GOPATH/bin in .bashrc, everything worked fine.

@beng
Copy link

beng commented Aug 26, 2016

I ran into this issue as well, but was able to fix it by running :GoUpdateBinaries

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

5 participants