duanhan8757 2019-08-08 18:15
浏览 119
已采纳

使用提交哈希时,出现模块“未知修订”错误

I need to pull this commit into my go project.

I've tried multiple versions of go.mod:

...

require (
    github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2

    // and...
    github.com/libp2p/go-libp2p-core v0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825
)

...

Both result in errors when running $ go build:

$ go build
go: finding github.com/libp2p/go-libp2p-core v0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825
go: finding github.com/libp2p/go-libp2p-core v0.0.7-0.20190626134135-aca080dccfc2
go: github.com/libp2p/go-libp2p-core@v0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825: unknown revision v0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825
go: github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2: unknown revision aca080dccfc2
go: error loading module requirements

Go getting doesn't work, either:

$ go get github.com/libp2p/go-libp2p-core@aca080dccfc2c9933df66baafe6cf9cc4f429825
go: finding github.com/libp2p/go-libp2p-core v0.0.7-0.20190626134135-aca080dccfc2                                                                                                    go: github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2: unknown revision aca080dccfc2
go: error loading module requirements

As @JimB points out, that hash wasn't merged and was rebased. So I tried to replace it with a new one, but it's still trying to fetch the old one?

$ go get github.com/libp2p/go-libp2p-core@v0.2.1-0.20190802003216-436d707f7cd0
go: finding github.com/libp2p/go-libp2p-core v0.0.7-0.20190626134135-aca080dccfc2
go: github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2: unknown revision aca080dccfc2
go: error loading module requirements
  • 写回答

1条回答 默认 最新

  • drb88830 2019-08-08 23:36
    关注

    For your most recent hash aca080dccfc2, was that merged to master, or what does that hash correspond to? From quick look, aca080dccfc2 does not appear to be on master, but I'm not sure what your expectations are regarding that commit.

    There are restrictions on what hashes are allowed with modules, for example from this slightly older comment in #27043:

    It is present in Git if you look at refs/pulls/nnnnn or whatever the ref is, but not in the main branches and tags. Recent changes cut the search down to main branches and tags, which is more appropriate.

    Trying to get that aca080dccfc2 hash does not work for me:

    $ go get github.com/libp2p/go-libp2p-core@436d707f7cd0
    go: finding github.com/libp2p/go-libp2p-core 436d707f7cd0
    go get github.com/libp2p/go-libp2p-core@436d707f7cd0: 
     github.com/libp2p/go-libp2p-core@436d707f7cd0: invalid version: unknown revision 436d707f7cd0
    

    On the other hand, the most recent commit on master does work for me:

    $ go get github.com/libp2p/go-libp2p-core@d204016fc64589d0
    

    (Side note: notice I was just using the commit hash by itself after the @. That can be handy in case there is something wrong with a pseudo-version).

    You mentioned:

    it's still trying to fetch the old one?

    I'm not sure if that is your primary issue, but in general if you are not sure where a version is coming from, a good place to start is often:

    go mod graph | grep <module-of-interest>

    or in your case:

    go mod graph | grep go-libp2p-core

    From the documentation:

    'go mod graph' prints the module requirement graph (with replacements applied) in text form. Each line in the output has two space-separated fields: a module and one of its requirements. Each module is identified as a string of the form path@version, except for the main module, which has no @version suffix.

    There are some more general troubleshooting tips for tracking down why a particular version is being used in this FAQ on the modules wiki:

    FAQ: What can I check if I am not seeing the expected version of a dependency?

    That said, it might be more interesting to first understand what commit you are expecting to work...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿