Skip to content

Build Fails Due to Dependency Version Mismatch #67

@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 gopkg.in/mailgun/mailgun-go.v1 in gopkg.in/mailgun/mailgun-go.v1 v1.1.1
go: github.com/sanathp/statusok/database imports
        github.com/Sirupsen/logrus: github.com/Sirupsen/logrus@v1.9.3: parsing go.mod:
        module declares its path as: github.com/sirupsen/logrus
                but was required as: github.com/Sirupsen/logrus

Result

The build fails with errors related to mismatched module path.

The error dependency is github.com/Sirupsen/logrus.

Reason

The error log suggests module path declaration github.com/sirupsen/logrus in go.mod, which is inconsistent with import path github.com/Sirupsen/logrus .

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 declaration for the dependency is replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v0.8.5. 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:


replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v0.8.5

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

replace github.com/codegangsta/cli => github.com/urfave/cli v1.22.9

require (
	github.com/Sirupsen/logrus v0.0.0-00010101000000-000000000000
	github.com/codegangsta/cli v0.0.0-00010101000000-000000000000
	github.com/influxdata/influxdb v1.11.8
	github.com/stretchr/testify v1.9.1-0.20241003162259-5dc934f9aa22 // indirect
	gopkg.in/mailgun/mailgun-go.v1 v1.1.1
)

require (
	github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
	github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
	github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
	github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
	github.com/google/go-cmp v0.6.0 // indirect
	github.com/onsi/ginkgo v1.16.5 // indirect
	github.com/onsi/gomega v1.36.2 // indirect
	github.com/pkg/errors v0.9.1 // indirect
	github.com/russross/blackfriday/v2 v2.0.1 // indirect
	github.com/shurcooL/sanitized_anchor_name v1.0.0 // 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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions