Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find package "." in #20

Closed
JonathanLorimer opened this issue Sep 8, 2021 · 16 comments · Fixed by #41 or #121 · May be fixed by #22
Closed

Cannot find package "." in #20

JonathanLorimer opened this issue Sep 8, 2021 · 16 comments · Fixed by #41 or #121 · May be fixed by #22

Comments

@JonathanLorimer
Copy link

JonathanLorimer commented Sep 8, 2021

Describe the bug
gomod2nix seems to struggle with go dependencies that are part of the repo and referenced by relative paths. When I try and package regen-network I am getting this error:

app/app.go:10:2: cannot find package "." in:
        /build/source/vendor/github.com/regen-network/regen-ledger/types/module
app/app.go:95:2: cannot find package "." in:
        /build/source/vendor/github.com/regen-network/regen-ledger/types/module/server
app/app.go:96:2: cannot find package "." in:
        /build/source/vendor/github.com/regen-network/regen-ledger/x/ecocredit
app/app.go:11:2: cannot find package "." in:
        /build/source/vendor/github.com/regen-network/regen-ledger/x/ecocredit/module

The issue seems to be with these dependencies. The relevant error sites are listed below:

I also think that this has something to do with the local replace directives here
To Reproduce
I created a repro repo here. You should just have to run nix build to get the error. Since the repo is a flake you can just run nix build github:JonathanLorimer/gomod-repro-1 without even cloning the repo.

Expected behavior
I expected this module to build without errors

Environment

  • OS name + version: NixOS 21.11 (Porcupine) x86_64
  • Version of the code: 67f22dd738d092c6ba88e420350ada0ed4992ae8

Additional context
I have very limited golang knowledge so there might be something completely wrong with the go side of things and I am just missing it. Thank you for your help in advance!

@JonathanLorimer
Copy link
Author

Getting this issue resolved will help me close informalsystems/cosmos.nix#19

@JonathanLorimer
Copy link
Author

Okay, I think I have identified what the issue is! These local, relative path, directives don't end up in the go.sum. This means that gomod2nix doesn't end up picking them up and they are missing from the vendor-env! I am not sure what the best solution to this is, right now I am trying to figure out a hacky work around to just splice in the dependency I need.

@573
Copy link

573 commented Mar 31, 2022

Have similar issue with packaging dasel.

@573
Copy link

573 commented Apr 26, 2022

Similar issue (Cannot find package "." in) when packaging https://github.com/mickael-menu/zk.
The customVendorSrc (#22) there would be https://github.com/aymerick/raymond/.

@573
Copy link

573 commented May 9, 2022

Adding nix-casync to the affected go software.

@adisbladis
Copy link
Member

This issue is not fully resolved but was auto-closed by Github when #41 was merged.

@adisbladis adisbladis reopened this May 29, 2022
@gregistech
Copy link

@JonathanLorimer Have you solved this issue for yourself? I got this too with Zitadel.
Trying to use your PR as a flake input resulted in some errors.

@gregistech
Copy link

gregistech commented Jun 27, 2022

This might be a different issue though? (There are not really local packages...)

../protoc-base/templates.go:9:2: cannot find package "." in:
        /build/source/gopath/src/github.com/zitadel/zitadel/vendor/github.com/Masterminds/sprig
../protoc-base/protoc_helper.go:12:2: cannot find package "." in:
        /build/source/gopath/src/github.com/zitadel/zitadel/vendor/github.com/golang/glog
../protoc-base/protoc_helper.go:13:2: cannot find package "." in:
        /build/source/gopath/src/github.com/zitadel/zitadel/vendor/github.com/golang/protobuf/proto
../protoc-base/protoc_helper.go:14:2: cannot find package "." in:
        /build/source/gopath/src/github.com/zitadel/zitadel/vendor/github.com/golang/protobuf/protoc-gen-go/plugin
../protoc-base/protoc_helper.go:15:2: cannot find package "." in:
        /build/source/gopath/src/github.com/zitadel/zitadel/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor
../protoc-base/templates.go:12:2: cannot find package "." in:
        /build/source/gopath/src/github.com/zitadel/zitadel/vendor/golang.org/x/tools/imports
authoption/options.pb.go:10:2: cannot find package "." in:
        /build/source/gopath/src/github.com/zitadel/zitadel/vendor/google.golang.org/protobuf/reflect/protoreflect
authoption/options.pb.go:11:2: cannot find package "." in:
        /build/source/gopath/src/github.com/zitadel/zitadel/vendor/google.golang.org/protobuf/runtime/protoimpl
authoption/options.pb.go:12:2: cannot find package "." in:
        /build/source/gopath/src/github.com/zitadel/zitadel/vendor/google.golang.org/protobuf/types/descriptorpb

I do override buildPhase, could that be the problem?

@gregistech
Copy link

Actually, this is still in the configurePhase, as I need to generate some go files there. Irrelevant to this issue then.

@0xmuralik
Copy link

Any fixes or workarounds for this?

@skykanin
Copy link

I just ran into this same issue. Are there any fixes or workarounds for this?

@peterldowns
Copy link

^ I have the same issue, here's a minimal repro. What is the current status of this repository -- is it maintained?

@ezdac
Copy link

ezdac commented Apr 4, 2023

@peterldowns - I hit a very similar issue at the same opentelemetry module.

@nix { "action": "setPhase", "phase": "buildPhase" }
building
Building subPackage .
go: finding module for package go.opentelemetry.io/otel/exporters/otlp/internal
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/exporter.go:22:2: cannot query module due to -mod=vendor

Internally the buildPhase seems to call go install -mod=vendor . but then tries to query for the module in the otel/exporter.go imports. Go install does not seem to allow this with the mod=vendor (this is the error).

Maybe go install tries to fetch the module because it can't find it in the vendored modules in a similar way that it cannot find package "." ?

@peterldowns
Copy link

@ezdac hmm, I'm not sure. I was not able to find a fix for this problem and I worked around it by removing opentelemetry as a dependency from my project (it wasn't necessary, thankfully). It doesn't seem like anyone is working on this issue and I myself am not inclined to. You may consider putting up an easy way to reproduce the failure you're receiving, similar to what I did, to help the maintainers out if in the future they decide to try to fix this.

@JonathanLorimer
Copy link
Author

fwiw I just switched to using buildGoMod119 from nixpkgs, example here. Might be worth it if you have to depend on a package that breaks gomod2nix.

@niklashhh
Copy link

I believe this issue is caused by the weird module structure of go.opentelemetry.io/otel/exporters. I changed populateVendorPath to be recursive as hinted by the TODO which fixed the issue in my case.

Here is some logs indicating that it had to go three directories deep to create the missing symlinks:

vendor-env> symlink error, trying /nix/store/93w4h87w5hd0sz90mx8bcbd539v58y56-otel_v1.16.0/exporters symlink /nix/store/93w4h87w5hd0sz90mx8bcbd539v58y56-otel_v1.16.0/exporters vendor/go.opentelemetry.io/otel/exporters: file exists
vendor-env> symlink error, trying /nix/store/93w4h87w5hd0sz90mx8bcbd539v58y56-otel_v1.16.0/exporters/otlp symlink /nix/store/93w4h87w5hd0sz90mx8bcbd539v58y56-otel_v1.16.0/exporters/otlp vendor/go.opentelemetry.io/otel/exporters/otlp: file exists
vendor-env> symlink error, trying /nix/store/93w4h87w5hd0sz90mx8bcbd539v58y56-otel_v1.16.0/exporters/otlp/internal symlink /nix/store/93w4h87w5hd0sz90mx8bcbd539v58y56-otel_v1.16.0/exporters/otlp/internal vendor/go.opentelemetry.io/otel/exporters/otlp/internal: file exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
9 participants