opentelemetry-collector icon indicating copy to clipboard operation
opentelemetry-collector copied to clipboard

`go install` fails for `mdatagen`

Open atoulme opened this issue 1 year ago • 17 comments

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/[email protected]):
        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 avatar Jan 12 '24 23:01 atoulme

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

bogdandrutu avatar Jan 23 '24 21:01 bogdandrutu

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.

atoulme avatar Jan 23 '24 21:01 atoulme

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

cpheps avatar Mar 29 '24 13:03 cpheps

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

khushhboo avatar Mar 31 '24 15:03 khushhboo

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

atoulme avatar Mar 31 '24 20:03 atoulme

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/[email protected]): 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.

khushhboo avatar Apr 01 '24 04:04 khushhboo

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

atoulme avatar Apr 11 '24 20:04 atoulme

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/[email protected]):
	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.

woody1872 avatar May 02 '24 16:05 woody1872

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

atoulme avatar May 02 '24 16:05 atoulme

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?

mmynk avatar May 06 '24 19:05 mmynk

still experiencing this when doing go install go.opentelemetry.io/collector/cmd/[email protected]

TamerSherif avatar Jul 01 '24 19:07 TamerSherif

Why was this closed? This is still an issue. Currently have to manually build mdatagen to get this to work.

go install go.opentelemetry.io/collector/cmd/mdatagen@latest

go: downloading go.opentelemetry.io/collector/cmd/mdatagen v0.106.1 go: go.opentelemetry.io/collector/cmd/mdatagen@latest (in go.opentelemetry.io/collector/cmd/[email protected]): 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.

fredyfredburger avatar Aug 08 '24 15:08 fredyfredburger

Why was this closed?

@fredyfredburger It's not closed.

mmynk avatar Aug 08 '24 16:08 mmynk

Derp; I saw "https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33603 Closed" and thought this ticket was closed. That's my bad!

fredyfredburger avatar Aug 08 '24 18:08 fredyfredburger

Since I did the dumb and commented something useless on this ticket, I'll try to redeem myself by adding a temporary solution for those finding this ticket like I did looking for an answer:

git clone https://github.com/open-telemetry/opentelemetry-collector.git
cd opentelemetry-collector/cmd/mdatagen
sed -i '/replace/d' go.mod
go install

fredyfredburger avatar Aug 08 '24 18:08 fredyfredburger