Skip to content

Build Fails Due to Dependency Version Mismatch #6

@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/pressly/chi/middleware in github.com/pressly/chi v1.5.5
go: github.com/seedifferently/nogo imports
        github.com/pressly/chi: github.com/pressly/chi@v1.5.5: parsing go.mod:
        module declares its path as: github.com/go-chi/chi
                but was required as: github.com/pressly/chi

Result

The build fails with errors related to mismatched module path.

The error dependency is github.com/pressly/chi.

Reason

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

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/pressly/chi is v2.1.1-0.20170513182333-59bb6dfa05ab+incompatible. 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/pressly/chi => github.com/go-chi/chi v1.5.5.

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/miekg/dns v1.1.49

require github.com/pressly/chi v2.1.1-0.20170513182333-59bb6dfa05ab+incompatible

require github.com/boltdb/bolt v1.3.2-0.20180301142923-fa91bb2ff81d

require (
	golang.org/x/mod v0.4.2 // indirect
	golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 // indirect
	golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
	golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2 // indirect
	golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)

replace github.com/codegangsta/cli => github.com/urfave/cli/v2 v2.27.4

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