Skip to content

Build Fails Due to Dependency Version Mismatch #2

@deer8888

Description

@deer8888

Description

While rebuilding the project using the latest version of Go, with Go's official recommendation to use gomodule for initialization and building, we found that the build process fails due to mismatched module path.

The following error log was produced during the build process:

......
go: finding module for package gopkg.in/yaml.v2
go: found gopkg.in/yaml.v2 in gopkg.in/yaml.v2 v2.4.0
go: found github.com/codahale/hdrhistogram in github.com/codahale/hdrhistogram v1.1.2
go: github.com/goburrow/melon/metrics imports
        github.com/codahale/metrics imports
        github.com/codahale/hdrhistogram: github.com/codahale/hdrhistogram@v1.1.2: parsing go.mod:
        module declares its path as: github.com/HdrHistogram/hdrhistogram-go
                but was required as: github.com/codahale/hdrhistogram

Result

The build fails with errors related to mismatched module path.

The error dependency is github.com/codahale/hdrhistogram.

Reason

The error log suggests module path declaration github.com/HdrHistogram/hdrhistogram-go in go.mod, which is inconsistent with import path github.com/codahale/hdrhistogram .

Proposed Solution

Solution 1

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/codahale/hdrhistogram is v0.0.0-20160325223216-360314142131. This version has correct module path declaration.

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

Solution 2

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

The analysis shows that the correct declaration for the dependency is replace github.com/codahale/hdrhistogram => github.com/HdrHistogram/hdrhistogram-go v1.1.2. This version is the latest version of the dependency.

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:


require github.com/gorilla/mux v1.6.2-0.20180501031136-ded0c29b24f9

require github.com/codahale/metrics v0.0.0-20150128043020-21165607e846

require github.com/ghodss/yaml v1.0.1-0.20220118164324-1e4101787d19

require github.com/goburrow/dynamic v0.0.0-20150304200938-e31770fbde58

require github.com/codahale/hdrhistogram v0.0.0-20160325223216-360314142131 // indirect

require (
	github.com/goburrow/gol v0.0.0-20161016221943-2d8c917c7cc4
	github.com/goburrow/validator v0.1.0
)

require (
	github.com/gorilla/context v1.1.2 // indirect
	gopkg.in/yaml.v2 v2.2.2 // indirect
)

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions