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

x/vgo: no such file or directory #25674

Closed
adamjacobmuller opened this issue May 31, 2018 · 3 comments
Closed

x/vgo: no such file or directory #25674

adamjacobmuller opened this issue May 31, 2018 · 3 comments
Milestone

Comments

@adamjacobmuller
Copy link

Please answer these questions before submitting your issue. Thanks!

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

[adam@adams-macbook]$ vgo version
go version go1.10.2 darwin/amd64 vgo:2018-02-20.1

Does this issue reproduce with the latest release?

yes

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

[adam@adams-macbook]$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/adam/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/adam/Scripts/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.2/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
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"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/9l/dqqy91t557j8lsrdv1w_krq00000gn/T/go-build692479027=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

cat <EOF>main.go
package main


import (
_ "github.com/mattes/migrate"
_ "github.com/mattes/migrate/database/cockroachdb"
_ "github.com/mattes/migrate/source/go-bindata"
)

func main() {
}
EOF
vgo vendor

What did you expect to see?

completed go.mod file

What did you see instead?

[adam@adams-macbook]$ vgo vendor
vgo: resolving import "github.com/mattes/migrate"
vgo: finding github.com/mattes/migrate (latest)
vgo: adding github.com/mattes/migrate v1.3.2
vgo: import "github.com/belugacdn/test" ->
	import "github.com/mattes/migrate/database/cockroachdb" [/Users/adam/Scripts/go/src/v/github.com/mattes/[email protected]/database/cockroachdb]: open /Users/adam/Scripts/go/src/v/github.com/mattes/[email protected]/database/cockroachdb: no such file or directory
vgo: import "github.com/belugacdn/test" ->
	import "github.com/mattes/migrate/source/go-bindata" [/Users/adam/Scripts/go/src/v/github.com/mattes/[email protected]/source/go-bindata]: open /Users/adam/Scripts/go/src/v/github.com/mattes/[email protected]/source/go-bindata: no such file or directory
vgo: import "github.com/belugacdn/test" ->
	import "github.com/mattes/migrate/database/cockroachdb" [/Users/adam/Scripts/go/src/v/github.com/mattes/[email protected]/database/cockroachdb]: open /Users/adam/Scripts/go/src/v/github.com/mattes/[email protected]/database/cockroachdb: no such file or directory
vgo: import "github.com/belugacdn/test" ->
	import "github.com/mattes/migrate/source/go-bindata" [/Users/adam/Scripts/go/src/v/github.com/mattes/[email protected]/source/go-bindata]: open /Users/adam/Scripts/go/src/v/github.com/mattes/[email protected]/source/go-bindata: no such file or directory
vgo: resolving import "github.com/fatih/color"
vgo: finding github.com/fatih/color (latest)
vgo: adding github.com/fatih/color v1.7.0
vgo: resolving import "gopkg.in/mattes/migrate.v1/driver/bash"
vgo: finding gopkg.in/mattes/migrate.v1 (latest)
vgo: adding gopkg.in/mattes/migrate.v1 v1.3.2

found this as part of a much larger project which is not using null imports, but, this reproducer was simpler and demonstrates the issue

@gopherbot gopherbot added this to the vgo milestone May 31, 2018
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 31, 2018
@ianlancetaylor
Copy link
Contributor

CC @rsc @bcmills

@myitcv
Copy link
Member

myitcv commented Jun 1, 2018

@adamjacobmuller the repro you provided doesn't seem like valid shell to me, so I've taken a guess at the following:

cd `mktemp -d`
export GOPATH=$PWD
mkdir hello
cd hello
cat <<EOD > main.go
package main // import "example.com/hello"


import (
  _ "github.com/mattes/migrate"
  _ "github.com/mattes/migrate/database/cockroachdb"
  _ "github.com/mattes/migrate/source/go-bindata"
)

func main() {
}
EOD

At this point we must create a go.mod to tell vgo we are a Go module:

echo > go.mod

Notice it will take the import path from main.go.

Now if we look at the available releases of github.com/mattes/migrate you will see the latest is v3.0.1. The thing to notice at this point is that this project has not been "converted" to be a Go module, that is there is no go.mod. This is important because it's major version is >= 2. As such for now we need to fallback to explicitly getting a version of github.com/mattes/migrate.

But then another thing to notice is that the CockroachDB support that you want to rely on has not actually made it to a release yet.

So taking these points together (project not converted to be a Go module, major version >= 2 and changes only available in master) we need to:

vgo get github.com/mattes/migrate@master

At which point we can see how go.mod has been changed:

cat go.mod

which gives:

module example.com/hello

require (
        github.com/cockroachdb/cockroach-go v0.0.0-20180212155653-59c0560478b7
        github.com/lib/pq v0.0.0-20180523175426-90697d60dd84
        github.com/mattes/migrate v0.0.0-20180508041624-4768a648fbd9
)

Notice the pseudo-versions being used, pseudo versions that correspond (at the time of writing) to the HEAD or master.

Finally do a build to check:

vgo build

I'll close this issue for now therefore because I think your expectation that vgo would create a go.mod file is not correct; you need to tell vgo where you want to define your module.

But if there are any other issues, please feel free to comment back here or open a new issue.

@myitcv myitcv closed this as completed Jun 1, 2018
@myitcv myitcv removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 1, 2018
@adamjacobmuller
Copy link
Author

@myitcv thanks, I was not aware of the vgo get github.com/mattes/migrate@master syntax to fetch a specific release, works perfectly!

Thank you,
-Adam

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

4 participants