Skip to content

Build Fails Due to Dependency Version Mismatch #16

@back678

Description

@back678

Description

While reproducing the project, we found that the build process fails due to mismatched or unresolved dependencies.

The following error log was produced during the build process:

......
go: found github.com/prometheus/client_golang/prometheus in github.com/prometheus/client_golang v1.20.5

go: finding module for package github.com/prometheus/common/log

go: github.com/nlamirault/pihole_exporter imports

    github.com/prometheus/common/log: module github.com/prometheus/common@latest found (v0.62.0), but does not contain package github.com/prometheus/common/log

Result

The build fails with errors related to missing or mismatched dependencies.

The error dependency is github.com/prometheus/common.

The build process automatically pulls the latest dependency versions by default. However, the required package github.com/prometheus/common/log is not included in version v0.62.0.

Reason

This issue appears to be caused by the absence of precise version tracking in GOPATH, which leads to inconsistency in dependency resolution.

Proposed Solution

To resolve this issue, we analyzed the project and identified the correct versions of the required dependencies.

The analysis shows that the correct version for the dependency github.com/prometheus/common is v0.26.0.

Consider adopting this suggested version to prevent other developers from encountering build failures when constructing the project.

This information can be documented in the README.md file or another relevant location.

Additional Suggestions

To ensure reproducible builds and align with the evolving trends of the Go programming language, it is recommended that the current project be migrated to the Go module mechanism.

Updating to the go module mechanism allows for managing third-party dependency versions through the go.mod file, which provides a centralized and consistent way to specify dependency constraints.

We have generated a go.mod file with the correct versions of the third-party dependencies needed for this project.

The suggested go.mod file is as follows:

module github.com/nlamirault/pihole_exporter

go 1.23

replace github.com/matttproud/golang_protobuf_extensions => github.com/matttproud/golang_protobuf_extensions/v2 v2.0.1-0.20240112091343-3664e70c352e

require github.com/beorn7/perks v1.0.1 // indirect

require github.com/sirupsen/logrus v1.9.2 // indirect

require github.com/prometheus/procfs v0.6.0 // indirect

require github.com/golang/protobuf v1.5.4 // indirect

require github.com/prometheus/common v0.26.0

require github.com/prometheus/client_golang v1.7.1

require github.com/prometheus/client_model v0.6.0 // indirect

require (
	github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
	github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
	github.com/cespare/xxhash/v2 v2.1.1 // indirect
	github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
	github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
	github.com/stretchr/testify v1.8.0 // indirect
	golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
	google.golang.org/protobuf v1.33.0 // indirect
	gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
)

Here the +incompatible suffix in go.mod indicates that the module does not follow Go Modules' semantic versioning (SemVer) rules correctly. But Go can still build and run the project normally despite the +incompatible tag.

Additional Information:

This issue was identified as part of our research project focused on automating the analysis of GOPATH projects to provide accurate dependency versions for seamless migration to Go Modules. We value your feedback and would appreciate any comments or suggestions regarding this approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions