You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm importing a package, go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc, whose version v0.48.0 has an ambiguous import path issue with cloud.google.com/go/compute/metadata:
go: test imports
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc tested by
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.test imports
google.golang.org/grpc/interop imports
golang.org/x/oauth2/google imports
cloud.google.com/go/compute/metadata: ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules:
cloud.google.com/go v0.34.0 (/home/anomalroil/go/pkg/mod/cloud.google.com/go@v0.34.0/compute/metadata)
cloud.google.com/go/compute/metadata v0.2.3 (/home/anomalroil/go/pkg/mod/cloud.google.com/go/compute/metadata@v0.2.3)
However, as you can see the offending package isn't go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc itself, but its named test package otelgrpc_test.
And yet, the following code allows to reproduce this:
This looks like a go mod tidy bug:
why should the named test package dependencies be imported in my own go module if I'm only using the "parent", non-test package?
NB. the underlying ambiguous path issue was fixed in open-telemetry/opentelemetry-go-contrib#4897 where you can clearly see the issue stem only from named test packages and not from the package I'm actually importing in my program.
What did you see happen?
$ go get go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc@v0.48.0
$ go get github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0
$ go mod tidy
go: mypackage imports
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc tested by
go.open telemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.test imports
google.golang.org/grpc/interop imports
golang.org/x/oauth2/google imports
cloud.google.com/go/compute/metadata: ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules:
cloud.google.com/go v0.26.0 (/home/anomalroil/go/pkg/mod/cloud.google.com/go@v0.26.0/compute/metadata)
cloud.google.com/go/compute/metadata v0.2.3 (/home/anomalroil/go/pkg/mod/cloud.google.com/go/compute/metadata@v0.2.3)
What did you expect to see?
When importing a package whose tests imports another package in a named test package (not same package as I'm importing), I would expect the test dependencies to be pruned and not causing any issues even in case of a ambiguous import path or whatnot since these are not packages I'm actually importing.
The text was updated successfully, but these errors were encountered:
go mod tidy works by loading all of the packages in the main module and all of the packages they import, recursively. This includes packages imported by tests (including tests in other modules).
the guiding idea has been it gets all the dependencies that allow you to run go test all.
Go version
go version go1.21.7 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I'm importing a package,
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
, whose versionv0.48.0
has an ambiguous import path issue withcloud.google.com/go/compute/metadata
:However, as you can see the offending package isn't
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
itself, but its named test packageotelgrpc_test
.And yet, the following code allows to reproduce this:
by running
go mod tidy
.This looks like a
go mod tidy
bug:why should the named test package dependencies be imported in my own go module if I'm only using the "parent", non-test package?
NB. the underlying ambiguous path issue was fixed in open-telemetry/opentelemetry-go-contrib#4897 where you can clearly see the issue stem only from named test packages and not from the package I'm actually importing in my program.
What did you see happen?
What did you expect to see?
When importing a package whose tests imports another package in a named test package (not same package as I'm importing), I would expect the test dependencies to be pruned and not causing any issues even in case of a
ambiguous import path
or whatnot since these are not packages I'm actually importing.The text was updated successfully, but these errors were encountered: