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

cmd/go: go build cannot find versioned package when in vendor folder #30798

Closed
ljr900723 opened this issue Mar 13, 2019 · 6 comments
Closed

cmd/go: go build cannot find versioned package when in vendor folder #30798

ljr900723 opened this issue Mar 13, 2019 · 6 comments

Comments

@ljr900723
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.12 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jrliu/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/jrliu/Projects/go_pkg:/Users/jrliu/Projects/common_git/src/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2f/dd68lmkj44xbb6t17wzr7mfr9snms2/T/go-build042915927=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

My project is based on "github.com/xitongsys" (which is based on "github.com/colinmarc/hdfs")
When I run "go build", there is no problem when those dependences are located in GOPATH/src.
When I move those dependences to myProject/vendor, and run "go build", the build will fail:

-->
vendor/github.com/colinmarc/hdfs/client.go:13:2: cannot find package "github.com/colinmarc/hdfs/v2/hadoopconf" in any of:
...

I know the "colinmarc/hdfs" uses the module-feature, and "github.com/colinmarc/hdfs/v2" is the name of module.

Can anybody help me and I cannot find any helpful information from the Internet.

What did you expect to see?

Build success

What did you see instead?

Build failed

@agnivade
Copy link
Contributor

Please give us the exact set of steps to reproduce this issue.

@ljr900723
Copy link
Author

@agnivade Thanks for your quick reply.

The step is as follows:

  1. Create a project (named "temp") with a go file written as:

package main

import (
"github.com/xitongsys/parquet-go/ParquetFile"
"github.com/xitongsys/parquet-go/ParquetWriter"
)

type Model struct {
F1 string parquet:"name=name, type=UTF8"
}

func main() {
// Write
fw, _ := ParquetFile.NewLocalFileWriter("/tmp/test.parquet")
pw, _ := ParquetWriter.NewParquetWriter(fw, new(Model), 4)
stu := Model{F1: "f1"}
pw.Write(stu)
fw.Close()
}

  1. Run "go get github.com/xitongsys/parquet-go/..." to get the required dependencies. Then you can get a lot of dependencies under "$GOPATH/src"

  2. Run "go build" under our project. Then the building is OK.

  3. Move all dependencies to "$GOPATH/src/temp/vendor".

  4. Run "go build" again. Then the building is failed like:

vendor/github.com/colinmarc/hdfs/client.go:13:2: cannot find package "github.com/colinmarc/hdfs/v2/hadoopconf" in any of:
...
vendor/github.com/colinmarc/hdfs/client.go:14:2: cannot find package "github.com/colinmarc/hdfs/v2/internal/protocol/hadoop_hdfs" in any of:
...
vendor/github.com/colinmarc/hdfs/client.go:15:2: cannot find package "github.com/colinmarc/hdfs/v2/internal/rpc" in any of:
...

Does this make sense?

@wenkaler
Copy link

I did everything that is written in your instructions and probably realized what the problem is. Maybe you forgot to create a subfolder in vendor github.com. I create a subfolder that solved your problem.

├── main.go
├── temp
└── vendor
    └── github.com
        └── xitongsys

@ljr900723
Copy link
Author

Thanks @wenkaler
But I think the dir structure should be (in my computer):
$GOPATH/src
|-- temp
|---- main.go
|---- vendor
|------ github.com/
|-------- xitongsys/...
|------ {other libs}/...

I don't think I forgot the "github.com" folder.
Thank you anyway.

@wenkaler
Copy link

Sorry, @ljr900723. I explain, temp is binary file program.

 …/go/src/temp: tree  -L 3                                                    
.
├── main.go
├── temp
└── vendor
    └── github.com
        └── xitongsys
 …/go/src/temp: ls -lah                                                   
total 16M
drwxr-xr-x  3 dmitriy dmitriy 4.0K Mar 14 18:00 .
drwxr-xr-x 10 dmitriy dmitriy 4.0K Mar 14 17:55 ..
-rw-r--r--  1 dmitriy dmitriy  388 Mar 14 17:57 main.go
-rwxr-xr-x  1 dmitriy dmitriy  16M Mar 14 18:09 temp
drwxr-xr-x  3 dmitriy dmitriy 4.0K Mar 14 18:00 vendor

@katiehockman
Copy link
Contributor

Please correct me if I'm wrong, but this sounds more like a question that would be more appropriate for a forum, rather than a bug in go build.

Closing this issue, but please continue the conversation using the guidelines at https://golang.org/wiki/Questions or continue the discussion here.

@katiehockman katiehockman changed the title go build cannot find versioned package when in vendor folder cmd/go: go build cannot find versioned package when in vendor folder Mar 19, 2019
@golang golang locked and limited conversation to collaborators Mar 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants