go mod fails to find version v0.0.0-00010101000000-000000000000 of a dependency

I'm trying to download all of the dependencies of a project via go mod; the problem occurs when it comes to execute go mod vendor on the CLI. The output is as follows:

go: finding github.com/hyperledger/fabric-sdk-go v0.0.0-00010101000000-000000000000
go: github.com/hyperledger/[email protected]: unknown revision 000000000000
go: error loading module requirements

The code that imports the libraries is this:

import (    
    "github.com/hyperledger/fabric-sdk-go/pkg/client/ledger"
    "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt"
    "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
)

krakengosdk is the name of the package I'm working on:

go mod init krakengosdk

Any solution? I've been looking for any solution for a while, but I haven't came across anything useful.

EDIT: I've updated the go version to 1.13; it seems like the error has to be with "github.com/hyperledger/fabric-sdk-go/test/[email protected]":

go get -v github.com/hyperledger/fabric-sdk-go/test/integration@latest
go: finding github.com/hyperledger/fabric-sdk-go/test/integration latest
go get: github.com/hyperledger/fabric-sdk-go/test/[email protected] requires
    github.com/hyperledger/[email protected]: invalid version: unknown revision 000000000000

Upvotes: 5

Views: 14139

Answers (5)

thepudds
thepudds

Reputation: 5294

Questions:

  1. What is your exact go.mod file?
  2. Do you have any replace directives for github.com/hyperledger/fabric-sdk-go?
  3. If you don't currently, did you at one time?

That long version v0.0.0-00010101000000-000000000000 is what usually shows up if you have a replace directive but don't have a corresponding require directive and the go command automatically adds a require directive for you using that long version.

That can be fine, but I wonder if you did something like added a replace, but then later removed the replace while leaving in place the long version v0.0.0-00010101000000-000000000000 in the require. Or something like that.

What happens if you:

  1. Remove any replace directives for github.com/hyperledger/fabric-sdk-go that you might have

  2. Change the require for github.com/hyperledger/fabric-sdk-go to be:

    require github.com/hyperledger/fabric-sdk-go latest
    
  3. Run go list -m all

Also, if not already, you should be using the latest release of Go 1.13, which fixes some bugs but also often has much better error messages.

Upvotes: 6

Alaska
Alaska

Reputation: 423

I am not sure if this solution would work for everyone, but I just did go get PACKAGE_WITH_ISSUE, so in your case:

go get github.com/hyperledger/fabric-sdk-go

Upvotes: 0

bitbuoy
bitbuoy

Reputation: 393

Error - the version that go is trying to pull for that specific module that imports it is either outdated or invalid.

Solution - For example in my case i was getting this error below:

go: downloading github.com/myk4040okothogodo/tutorial/gen/go/proto/books v0.0.0-00010101000000-000000000000
github.com/myk4040okothogodo/tutorial/books imports
    github.com/myk4040okothogodo/tutorial/books/server imports
    github.com/myk4040okothogodo/tutorial/gen/go/proto/books: github.com/myk4040okothogodo/tutorial/gen/go/proto/[email protected]: invalid version: unknown revision 000000000000

as you can see above my module "github.com/myk4040okothogodo/tutorial/books/server" imports another module "github.com/myk4040okothogodo/tutorial/gen/go/proto/books:" this import throws the error above, so i go to my go.mod file and make the following changes:

 1 module github.com/myk4040okothogodo/tutorial/books/server                                                                                                           
  2 
  3 go 1.18
  4 
  5 replace github.com/myk4040okothogodo/tutorial/db => ../../db
  6 
  7 replace github.com/myk4040okothogodo/tutorial/gen/go/proto/books => ../../gen/go/proto/books
  8 
  9 require (
 10   github.com/arangodb/go-driver v1.3.2
 11   github.com/myk4040okothogodo/tutorial/db v0.0.0-00010101000000-000000000000
 12   github.com/myk4040okothogodo/tutorial/gen/go/proto/books latest
 13   google.golang.org/grpc v1.47.0
 14 )

check above in line 12 where i put "latest" instead of the version number i.e "v0.0.0...."

I save the file and then i run "go mod tidy"

The compiler then changes the "latest" designation to an up to date version,i.e it will look as below after running the mod tidy command.

1 module github.com/myk4040okothogodo/tutorial/books/server                                                                                                           
  2 
  3 go 1.18
  4 
  5 replace github.com/myk4040okothogodo/tutorial/db => ../../db
  6 
  7 replace github.com/myk4040okothogodo/tutorial/gen/go/proto/books => ../../gen/go/proto/books
  8 
  9 require (
 10   github.com/arangodb/go-driver v1.3.2
 11   github.com/myk4040okothogodo/tutorial/db v0.0.0-00010101000000-000000000000
 12   github.com/myk4040okothogodo/tutorial/gen/go/proto/books v0.0.0-20220601171028-60237b9c9583
 13   google.golang.org/grpc v1.47.0
 14 )

PS: check the package where i make the changes, dont change the wrong imports

Upvotes: 2

Shubham Singh
Shubham Singh

Reputation: 361

This happened to me because of using replace flag and removing the replace flag. This can be corrected with use of below two commands.

go mod edit -droprequire=github.com/hyperledger/fabric-sdk-go

Above command drops the dependency

go mod tidy

Above command re-downloads the dependency.

Upvotes: 5

Alex Yu
Alex Yu

Reputation: 3547

Proposed diagnostics

I suggest to try those commands in console (bash/dash/fish/zsh):


# 1. Create clean project 
$ mkdir /tmp/checkmods && cd /tmp/checkmods  # create clean directory
$ export GO111MODULES=on
$ go version # check that version 1.13
$ go mod init main # name of package does not matter here

# 2. Install packages, check output
$ go get -v github.com/hyperledger/fabric-sdk-go/pkg/client/ledger
$ go get -v github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt
$ go get -v github.com/hyperledger/fabric-sdk-go/pkg/fabsdk

# 3. Create main.go 
$ touch main.go
$ # edit main.go, add imported packages, import something from those packages
$ go mod vendor 
# Do you have problems here? 
# if you encounter problems: 
# - play around  with `go mod tidy`
# - look at `go.mod` and `go.sum`
# - `go mod graph/verify/why` - are your friends

Example of main.go:

package main

import (
    "fmt"
    "github.com/hyperledger/fabric-sdk-go/pkg/client/ledger"
    "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt"
    "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
)

func main() {
    var (
        cln  &ledger.Client
        rsm  &resmgmt.Client
        fbs  &fabsdk.FabricSDK
    )
    fmt.Printf("%T %T %T\n", cln, rsm, fbs)
}

Analysis

If you encounter problems: explain on which line you encountered, what kind of problem.

If everything OK with clean start: look what is different between your project and clean start (diffs for go.sum & go.mod)

Good luck!

Upvotes: 1

Related Questions