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 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计