golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.3k stars 611 forks source link

`running "mockgen": exec: "mockgen": executable file not found in $PATH` #642

Closed vitaly-zdanevich closed 2 years ago

vitaly-zdanevich commented 2 years ago

I have this error on go generate ./...

BUT

$ mockgen --version v1.6.0

$ which mockgen /home/vitaly/go/bin/mockgen

First line of the file from error: //go:generate mockgen -source=interface.go -destination=interface_mock.go -package=alarms

In go.mod I have: github.com/golang/mock v1.6.0

go mod tidy do nothing.

go 1.17.8

Gentoo Linux

Bash

codyoss commented 2 years ago

Sounds like you may need to add mockgen to your PATH. Please take a look at the note in the installation instructions. Hope that helps!

vitaly-zdanevich commented 2 years ago

In my PATH I already have PATH=~/go/bin

codyoss commented 2 years ago

@vitaly-zdanevich what happens when you type which mockgen in your terminal?

vitaly-zdanevich commented 2 years ago

As in original post:

/home/vitaly/go/bin/mockgen

codyoss commented 2 years ago

Does it work if you manually run the command from you terminal instead of go generate?

vitaly-zdanevich commented 2 years ago

Yes.

vitaly-zdanevich commented 2 years ago

SOLVED. Problem was that in PATH I had ~/go/bin but must be /home/vitaly/go/bin/

vitaly-zdanevich commented 2 years ago

Did a related PR https://github.com/golang/mock/pull/644