Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

go get with go1.8 causes "unexpected directory layout" error on first try #242

Closed
shawnps opened this issue Feb 24, 2017 · 11 comments
Closed

Comments

@shawnps
Copy link
Contributor

shawnps commented Feb 24, 2017

Running go get -u -v github.com/alecthomas/gometalinter first time causes this error:

  ~ go get -u -v github.com/alecthomas/gometalinter
github.com/alecthomas/gometalinter (download)
github.com/google/shlex (download)
Fetching https://gopkg.in/alecthomas/kingpin.v3-unstable?go-get=1
Parsing meta tags from https://gopkg.in/alecthomas/kingpin.v3-unstable?go-get=1 (status code 200)
get "gopkg.in/alecthomas/kingpin.v3-unstable": found meta tag main.metaImport{Prefix:"gopkg.in/alecthomas/kingpin.v3-unstable", VCS:"git", RepoRoot:"https://gopkg.in/alecthomas/kingpin.v3-unstable"} at https://gopkg.in/alecthomas/kingpin.v3-unstable?go-get=1
gopkg.in/alecthomas/kingpin.v3-unstable (download)
github.com/alecthomas/units (download)
github.com/nicksnyder/go-i18n (download)
Fetching https://gopkg.in/yaml.v2?go-get=1
Parsing meta tags from https://gopkg.in/yaml.v2?go-get=1 (status code 200)
get "gopkg.in/yaml.v2": found meta tag main.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at https://gopkg.in/yaml.v2?go-get=1
gopkg.in/yaml.v2 (download)
unexpected directory layout:
	import path: github.com/google/shlex
	root: /Users/shawn/mygo/src
	dir: /Users/shawn/mygo/src/github.com/alecthomas/gometalinter/vendor/github.com/google/shlex
	expand root: /Users/shawn/mygo/src
	expand dir: /Users/shawn/mygo/src/github.com/alecthomas/gometalinter/vendor/src/github.com/google/shlex
	separator: /

Running a second time seems to fix. Go version is Go 1.8.

@alecthomas why is there a src dir in the vendor folder? Doesn't seem used.

@alecthomas
Copy link
Owner

alecthomas commented Feb 24, 2017

Hmm, weird.

There is a src directory because Go does not support installing binaries from vendor. To work around this, I set the GOPATH to the vendor directory. I use the vendor directory so that tooling to update these dependencies works correctly.

@shawnps
Copy link
Contributor Author

shawnps commented Feb 24, 2017

@alecthomas personally I find it confusing to have anything in the vendor dir that's not being imported in the code outside of vendor/. My suggestion would be to stick the vendored linters into a separate dir, maybe vendored_linters/ and have vendor/ contain only the code that is imported like github.com/google/shlex etc. If left the way it is currently, it will likely cause confusion for users upgrading to 1.8 (I know some other people who also got this error on the first pass).

@alecthomas
Copy link
Owner

As I said, the vendoring tooling does not support that (which is not surprising, as it's an unusual use-case), and previously this was not a problem. However, obviously that's no longer the case so I'll have to come up with an alternate plan.

@shawnps
Copy link
Contributor Author

shawnps commented Feb 24, 2017

@alecthomas you can't set the GOPATH to vendored_linters/ rather than vendor/?

@alecthomas
Copy link
Owner

Yes, that I can do, but the vendoring tool (gvt) does not support alternate directories. I'll probably end up having two separate gvt trees: _linters/vendor/... and vendor/...

@shawnps
Copy link
Contributor Author

shawnps commented Feb 24, 2017

@alecthomas okay, I don't know the semantics of that tool, but it looks like you're doing the GOPATH stuff in main.go, so I assumed you could just stick everything in a folder like vendored_linters, add those to GOPATH, then the Go toolchain itself would take care of the vendor dir.

You obviously know the code much better than me so I'll leave it to you. Thanks for looking into it!

@alecthomas
Copy link
Owner

Okay, give that a try. Let me know if it works now.

@shawnps
Copy link
Contributor Author

shawnps commented Feb 24, 2017

@alecthomas I can confirm it works for me - did rm -rf $GOPATH/src/github.com/alecthomas/gometalinter and then:

➜  ~ go get -u -v github.com/alecthomas/gometalinter
github.com/alecthomas/gometalinter (download)
github.com/alecthomas/gometalinter/vendor/github.com/google/shlex
github.com/alecthomas/gometalinter/vendor/github.com/alecthomas/units
github.com/alecthomas/gometalinter/vendor/github.com/nicksnyder/go-i18n/i18n/language
github.com/alecthomas/gometalinter/vendor/gopkg.in/yaml.v2
github.com/alecthomas/gometalinter/vendor/github.com/nicksnyder/go-i18n/i18n/translation
github.com/alecthomas/gometalinter/vendor/github.com/nicksnyder/go-i18n/i18n/bundle
github.com/alecthomas/gometalinter/vendor/github.com/nicksnyder/go-i18n/i18n
github.com/alecthomas/gometalinter/vendor/gopkg.in/alecthomas/kingpin.v3-unstable
github.com/alecthomas/gometalinter

All seems good. Thanks for the very fast turnaround.

@alecthomas
Copy link
Owner

alecthomas commented Feb 24, 2017 via email

@nathany
Copy link

nathany commented Dec 8, 2017

Might be worth mentioning in the README installation section? The rm -rf worked. Thanks @shawnps.

(go version go1.8.5 darwin/amd64)

@chlarsen
Copy link

chlarsen commented Feb 6, 2018

This did it. Thank you so much for your help and patience!

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

No branches or pull requests

4 participants