Skip to content

Build Fails Due to Dependency Version Mismatch #26

@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: found github.com/trustpath/sequence in github.com/trustpath/sequence v0.0.0-20170322205949-e211dc167136
go: found github.com/stretchr/testify/require in github.com/stretchr/testify v1.9.0
go: github.com/zentures/sequence imports
        github.com/willf/bitset: github.com/willf/bitset@v1.14.2: parsing go.mod:
        module declares its path as: github.com/bits-and-blooms/bitset
                but was required as: github.com/willf/bitset

Result

The build fails with errors related to mismatched module path.

The error dependency is github.com/willf/bitset.

Reason

The error log suggests module path declaration github.com/bits-and-blooms/bitset in go.mod, which is inconsistent with import path github.com/willf/bitset .

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/willf/bitset is v1.1.4-0.20180717154336-95e7f391b5d9. 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/willf/bitset => github.com/bits-and-blooms/bitset v1.14.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/inconshreveable/mousetrap v1.1.0 // indirect

require github.com/willf/bitset v1.1.4-0.20180717154336-95e7f391b5d9

require github.com/stretchr/testify v1.8.4

require github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect

replace github.com/cpuguy83/go-md2man => github.com/cpuguy83/go-md2man/v2 v2.0.3

require github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace // indirect

require github.com/spf13/cobra v0.0.7

require (
	github.com/BurntSushi/toml v1.4.1-0.20240615085220-eb727477b3f7
	github.com/surge/glog v0.0.0-20141108051140-2578deb2b95c
	github.com/trustpath/sequence v0.0.0-20170322205949-e211dc167136
	github.com/zhenjl/porter2 v0.0.0-20150829210152-56e4718818e8
	github.com/zhenjl/xparse v0.0.0-20151026232530-92c1990d3c16
)

require (
	github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
	golang.org/x/net v0.19.0 // indirect
	golang.org/x/text v0.14.0 // indirect
	gopkg.in/yaml.v3 v3.0.1 // 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