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

Spurious "goimports does not support srcdir" error when trying to use :GoImports #1006

Closed
flowchartsman opened this issue Aug 13, 2016 · 2 comments

Comments

@flowchartsman
Copy link
Contributor

flowchartsman commented Aug 13, 2016

Actual behavior

:GoImports results in

vim-go: vim-go: goimports does not support srcdir. update with: :GoUpdateBinaries

But the version I have supports this.

Possible dup of closed issue #775

Expected behavior

:GoImports works, or at least gives an error message that is correct.

Steps to reproduce:

Run :GoImports

Environment

This is on OSX El Capitan 10.11.6 and is not in a Tmux session (but it also occurs there).

: echo system("goimports --help")

usage: goimports [flags] [path ...]
  -cpuprofile string
        CPU profile output
  -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
  -local string
        put imports beginning with this string after 3rd-party packages
  -memprofile string
        memory profile output
  -memrate int
        if > 0, sets runtime.MemProfileRate
  -srcdir dir
        choose imports as if source code is from dir. When operating on a single
 file, dir may instead be the complete file name.
  -trace string
        trace profile output
  -v    verbose logging
  -w    write result to (source) file instead of stdout

Press ENTER or type command to continue

:echo system("which goimports")

/Users/alaska/go/bin/goimports

Press ENTER or type command to continue

And, from the terminal:

$ which goimports
/Users/alaska/go/bin/goimports
@flowchartsman
Copy link
Contributor Author

flowchartsman commented Aug 13, 2016

Update

The error is correct. This was occurring in a different gopath that had an old copy of goimports sticking around in $GOPATH/bin. However, the debugging steps given in #775 were inadequate. It would be better to check which binary is being used with

:echo go#path#CheckBinPath("goimports")

That revealed the issue, and removing the old binary fixed the problem.

Recommendations

  • put the full path of the binary in the error message to make this clear.

@fatih fatih closed this as completed in a5222bf Aug 27, 2016
@fatih
Copy link
Owner

fatih commented Aug 27, 2016

Thanks @alaska. I've changed it so it prints the path.

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