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: vgo install of submodule modifies root go.mod #24749

Closed
myitcv opened this issue Apr 7, 2018 · 2 comments

Comments

@myitcv
Copy link
Member

commented Apr 7, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10.1 linux/amd64 vgo:2018-02-20.1

Specifically vgo is as of 5db81b5cd6ab5ee1dd1b1b0ee0843f194ab7b908

Does this issue reproduce with the latest release?

Yes.

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/.mountpoints/x"
GORACE=""
GOROOT="/home/myitcv/gos"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_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=/tmp/go-build749051986=/tmp/go-build -gno-record-gcc-switches"
VGOMODROOT=""

What did you do?

Edit: edited original issue to make it not depend on myitcv.io/... packages.

cd `mktemp -d`
echo 'module "rubbish.com"' > go.mod

# make blah submodule
mkdir blah
cd blah

echo 'module "rubbish.com/blah"' > go.mod

# create skeleton implementation that depends on external code
cat <<EOD > blah.go
package blah

import _ "rsc.io/pdf"
EOD

vgo build

which gives the expected output:

vgo: resolving import "rsc.io/pdf"
vgo: finding rsc.io/pdf (latest)
vgo: adding rsc.io/pdf v0.0.0-20180112171046-225057252246
vgo: finding rsc.io/pdf v0.0.0-20180112171046-225057252246
vgo: downloading rsc.io/pdf v0.0.0-20180112171046-225057252246

We can also vgo list as expected:

vgo list -f "{{printf \"%#v\"  .Module}}" .
vgo list -f "{{printf \"%#v\"  .Module}}" rubbish.com/blah

gives the expected:

modinfo.ModulePublic{Top:true, Path:"rubbish.com/blah", Version:""}
modinfo.ModulePublic{Top:true, Path:"rubbish.com/blah", Version:""}

But then if we move to the parent (?) module and vgo list:

cd ..
vgo list .

we get the possibly-to-be expected:

vgo: import "rubbish.com" [/tmp/tmp.Q8I5ISBSzQ]: no Go source files

(although I think you could argue that a module doesn't need to contain source files, it can just contain other modules?)

But then if we:

vgo list ./...

we get:

vgo: resolving import "rsc.io/pdf"
vgo: finding rsc.io/pdf (latest)
vgo: adding rsc.io/pdf v0.0.0-20180112171046-225057252246
rubbish.com/blah

The last line is fine, but the resolving of "rsc.io/pdf" is unexpected because that requirement only exists for the submodule (we are currently in top module directory).

The "rubbish.com" go.mod file has also been modified:

$ cat go.mod
module "rubbish.com"

require "rsc.io/pdf" v0.0.0-20180112171046-225057252246

which is unexpected.

What did you expect to see?

  • The root go.mod file to be untouched
  • No resolving required when doing vgo list ./... at the top module level

What did you see instead?

Per above.

@gopherbot gopherbot added this to the vgo milestone Apr 7, 2018

@myitcv

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2018

Updated this issue description to include a standalone example.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jun 6, 2018

This is a dup of #24605 - ... has to avoid walking into directories containing go.mod files.

@rsc rsc closed this Jun 6, 2018

@golang golang locked and limited conversation to collaborators Jun 6, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.