open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.06k stars 1.36k forks source link

`go install` fails for `mdatagen` #9281

Open atoulme opened 5 months ago

atoulme commented 5 months ago

Expected:

cd /tmp
go install github.com/open-telemetry/opentelemetry-collector/cmd/mdatagen@latest

should install mdatagen under $GOBIN.

Actual:

go install github.com/open-telemetry/opentelemetry-collector/cmd/mdatagen@latest
go: github.com/open-telemetry/opentelemetry-collector/cmd/mdatagen@latest (in github.com/open-telemetry/opentelemetry-collector/cmd/mdatagen@v0.92.0):
        The go.mod file for the module providing named packages contains one or
        more replace directives. It must not contain directives that would cause
        it to be interpreted differently than if it were the main module.
bogdandrutu commented 5 months ago

Not sure if this is a real problem, because this seem to work in CI, see https://github.com/open-telemetry/opentelemetry-collector/blob/main/.github/workflows/build-and-test.yml#L120 and https://github.com/open-telemetry/opentelemetry-collector/blob/main/Makefile#L81

atoulme commented 5 months ago

It works in this repository, but not under a different folder. This means we can't use it for contrib. I have amended the steps to reproduce.

cpheps commented 3 months ago

We are also experiencing this when trying to install the mdatagen tool via go install for our distribution.

khushhboo commented 2 months ago

Is there a fix for this yet? Trying to update some generated files in vcenterreceiver.

atoulme commented 2 months ago

Weird, please make sure you are on latest main and run make generate.

khushhboo commented 2 months ago

Issue persists, tried from inside a folder and from repository as well. Make generate fails.

Error displayed after go install github.com/open-telemetry/opentelemetry-collector/cmd/mdatagen@latest: go: go.opentelemetry.io/collector/cmd/mdatagen@latest (in go.opentelemetry.io/collector/cmd/mdatagen@v0.97.0): The go.mod file for the module providing named packages contains one or more replace directives. It must not contain directives that would cause it to be interpreted differently than if it were the main module.

atoulme commented 2 months ago

Please check that GOBIN is in your PATH. This might be the problem.

woody1872 commented 1 month ago

Also seeing this issue:

$ go install github.com/open-telemetry/opentelemetry-collector/cmd/mdatagen@latest
go: github.com/open-telemetry/opentelemetry-collector/cmd/mdatagen@latest (in github.com/open-telemetry/opentelemetry-collector/cmd/mdatagen@v0.99.0):
    The go.mod file for the module providing named packages contains one or
    more replace directives. It must not contain directives that would cause
    it to be interpreted differently than if it were the main module.
atoulme commented 1 month ago

I also can still reproduce. The way contrib works around this is by importing mdatagen into a go.mod first, and then install from there: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/Makefile#L283

mmynk commented 1 month ago

Some traction on this would be appreciated.

Trying to understand why the replace directives were added in the first place in #9358. What issue does that solve?