"cannot find module providing package" when specifying go 1.23 in go.mod
I'm attempting to build bicipi with gomod2nix and coming across the following error:
$ nix build .#packages.x86_64-linux.bicipi
[...]
error: builder for '/nix/store/4sp13glivjl3h1zihnn8vzzl3i1rr24x-bicipi-0.1.drv' failed with exit code 1;
last 18 log lines:
> Running phase: unpackPhase
> unpacking source archive /nix/store/vzibmb9578q8ghhay6dx09n84xi7qx9w-57s3c5a6xzrfn69af4z5d4xmfxywcl59-source
> source root is 57s3c5a6xzrfn69af4z5d4xmfxywcl59-source
> Running phase: patchPhase
> Running phase: updateAutotoolsGnuConfigScriptsPhase
> Running phase: configurePhase
> Running phase: buildPhase
> Building subPackage .
> go: ignoring package github.com/sirupsen/logrus which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.
> go: ignoring package tinygo.org/x/bluetooth which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.
> go: ignoring package github.com/montanaflynn/stats which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.
> go: ignoring package go.bug.st/serial which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.
> go: ignoring package github.com/google/gousb which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go mod vendor.
> ftms/fitness_machine_service.go:6:2: cannot find module providing package github.com/sirupsen/logrus: import lookup disabled by -mod=vendor
> ftms/commands.go:8:2: cannot find module providing package tinygo.org/x/bluetooth: import lookup disabled by -mod=vendor
> tacx/tacx.go:9:2: cannot find module providing package github.com/montanaflynn/stats: import lookup disabled by -mod=vendor
> tacx/serial/commander.go:9:2: cannot find module providing package go.bug.st/serial: import lookup disabled by -mod=vendor
> tacx/usb/commander.go:8:2: cannot find module providing package github.com/google/gousb: import lookup disabled by -mod=vendor
For full logs, run 'nix log /nix/store/4sp13glivjl3h1zihnn8vzzl3i1rr24x-bicipi-0.1.drv'.
That's almost all of the direct dependencies failing (github.com/google/go-cmp seems ok...?)
I suppose this might be related to https://github.com/nix-community/gomod2nix/issues/20, but it looks like that was resolved.
Any support would be much appreciated.
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/gomod2nix-cannot-find-module-providing-package/54558/4
Gday mate - I ended up getting this working, and have a repo with it. Hopefully this is useful. https://github.com/randomizedcoder/gomod2nix-example
@randomizedcoder thanks for your response.
I'd been banging my head against this wall for some days when you responded, at which point I decided to bang some more. It turns out that the fix is to downgrade go.mod from 1.23 to 1.22. Even though the go version locked in the flake's nixpkgs is 1.23, along with inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs".
The version in your go.mod is 1.17. Do you remember what it was that fixed this problem for you?
I hope this helps others to move forward, but I'm concerned that versions beyond 1.22 are all going to be broken. I'll rename this issue to better reflect the problem and see if I can continue my investigation at some point.
@rcambrj
Actually, I tried to create a PR to update the go version. Go 1.23 has a bunch of very nice improvements, particularly for timers.
https://github.com/nix-community/gomod2nix/pull/173
@randomizedcoder I still get cannot find module providing package when switching gomod2nix to your branch:
inputs.gomod2nix.url = "github:randomizedcoder/gomod2nix?ref=update";
I'm not sure what's broken, but I don't think that's it 🙁