Skip to content

Build Fails Due to Dependency Version Mismatch #97

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/codegangsta/cli in github.com/codegangsta/cli v1.22.15
go: found github.com/smartystreets/goconvey/convey in github.com/smartystreets/goconvey v1.8.1
go: github.com/moul/ssh2docker/cmd/ssh2docker imports
        github.com/codegangsta/cli: github.com/codegangsta/cli@v1.22.15: parsing go.mod:
        module declares its path as: github.com/urfave/cli
                but was required as: github.com/codegangsta/cli

Result

The build fails with errors related to mismatched module path.

The error dependency is github.com/codegangsta/cli.

Reason

The error log suggests module path declaration github.com/urfave/cli in go.mod, which is inconsistent with import path github.com/codegangsta/cli .

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/codegangsta/cli => github.com/urfave/cli v1.22.9.

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/apex/log v1.8.1-0.20200817094143-421394d88c94

require github.com/parnurzeal/gorequest v0.3.1-0.20240221155414-2f6d15e4738b

require github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568

require github.com/pkg/errors v0.9.2-0.20201214064552-5dd12d0cfe7f // indirect

require github.com/stretchr/testify v1.10.0 // indirect

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

require github.com/mitchellh/go-homedir v1.1.0

require github.com/kr/pty v1.1.8

require github.com/creack/pty v1.1.23 // indirect

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

replace github.com/moul/http2curl => moul.io/http2curl/v2 v2.3.1-0.20221024080105-10c404f653f7

require (
	github.com/codegangsta/cli v0.0.0-00010101000000-000000000000
	github.com/smartystreets/goconvey v1.8.1
	golang.org/x/crypto v0.32.0
)

require (
	github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
	github.com/elazarl/goproxy v1.7.0 // indirect
	github.com/gopherjs/gopherjs v1.17.2 // indirect
	github.com/jtolds/gls v4.20.0+incompatible // indirect
	github.com/russross/blackfriday/v2 v2.0.1 // indirect
	github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
	github.com/smarty/assertions v1.15.0 // indirect
	golang.org/x/net v0.34.0 // indirect
	golang.org/x/sys v0.29.0 // indirect
	moul.io/http2curl 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