Open forrestlinfeng opened 1 month ago
Looks like the binary of mockgen is broken. I will update a new one.
@forrestlinfeng Didn't reproduce, which os are you using? Windows?
I have tried the new binary on Linux and macOS and didn't reproduce the error message.
linux/mac,现在trpc create都跑不起来了
wineandchord @.***> 于2024年5月21日周二 17:03写道:
I have tried the new binary on Linux and macOS and didn't reproduce the error message.
— Reply to this email directly, view it on GitHub https://github.com/trpc-group/trpc-go/issues/180#issuecomment-2122134071, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACXXREG553VRN7D6SMQTE4TZDMEX7AVCNFSM6AAAAABIA5XVYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRSGEZTIMBXGE . You are receiving this because you were mentioned.Message ID: @.***>
@forrestlinfeng Can you give detailed go env
and steps to reproduce? As per discussion, we are unable to find the root cause given the information provided thus far.
@forrestlinfeng I think I have figured out the root cause:
The go src code here. Quoted as:
// Default is the default Context for builds.
// It uses the GOARCH, GOOS, GOROOT, and GOPATH environment variables
// if set, or else the compiled code's GOARCH, GOOS, and GOROOT.
var Default Context = defaultContext()
So, the newly compiled mockgen binary contains my GOROOT information. If users do not have go env GOROOT
or system variable GOROOT
set, go build/go list
will use the GOROOT information compiled inside the go binary.
Quick fix:
export GOROOT="$(dirname "$(dirname "$(which go)")")"
But I am still curious about on what occasion the GOROOT will not be set by default? And why there wasn't any error message previously (maybe the previous compiled GOROOT information coincides with the user's local environment)?
What version of tRPC-Go are you using?
v0.0.1
trpc create遇到这个问题
trpc create err:exit status 1, reason:Execution err: running plugin
mockgen
, err: go mock mockgen err: cmd exec err: exit status 1, msg:2024/05/21 11:01:16 Loading input failed: makephoto.trpc.go:44:2: could not parse package trpc.group/trpc-go/trpc-go/server: go/build: go list trpc.group/trpc-go/trpc-go/server: fork/exec /Users/guoqizhou/go/go1.21.2/bin/go: no such file or directory , if the error is caused by 'go mod tidy' or 'mockgen', you may try adding '--nogomod' flag to use the outer go.mod of your project, or you can use '--mock=false' to disable go mod tidy and mockgen completely, if you are very curious, here's the explanation: Most of the errors are basically caused by the mockgen tool. Before executing mockgen, it requires running go mod tidy, which in turn needs a valid go.mod file. However, this go.mod file can have various issues, especially when your project already has an existing go.mod file. Therefore, using the '--nogomod' flag to disable the generation of a new go.mod file can solve the problem, or using the '--mock=false' flag can resolve the issue even more effectively (but there won't be any mock files generated :( ). Please run "trpc -h" or "trpc create -h" (or "trpc {some-other-subcommand} -h") for help messages.