'protoc-gen-go-grpc: program not found or is not executable', despite all the efforts - go

I'm trying to run makefile command 'gen' from this project https://github.com/penthaapatel/grpcblog. The command is: protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative blog/blog.proto However I get an error:
protoc-gen-go-grpc: program not found or is not executable
--go-grpc_out: protoc-gen-go-grpc: Plugin failed with status code 1.
make: *** [/home/deckard/go/src/grpcblog/Makefile:2: gen] Error 1
I use Ubuntu 20.04? Golang-1.13.8 with $GOROOT=/usr/lib/go-1.13 and $GOPATH=/home/deckard/go ($HOME is /home/deckard). Protoc is libprotoc v.3.6.1.. I installed protobuf-compiler both with:
sudo apt install protobuf-compiler
and
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
There's a folder /home/deckard/go/src/github.com/golang/protobuf and /home/deckard/go/src/google.golang.org/protobuf with /home/deckard/go/src/google.golang.org/protobuf, with, I guess, everything i need.
My bashrc configurations (tried few methods, so things overlap each other):
export GOROOT=/usr/lib/go-1.13
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT:$GOPATH:$GOBIN
export PATH=$PATH:$GOPATH/bin
export GO_PATH=~/go
export PATH=$PATH:/$GO_PATH/bin
So i tried solutions from here: protoc-gen-go: program not found or is not executable, but none of them helped me. Any clue would be helpful, because I stuck and am very tired.
UPDATE: ls -l /home/deckard/go/bin/protoc-gen-go-grpc shows rwxrwxr-x 1 deckard deckard 7970222 мая 1 14:55 /home/deckard/go/bin/protoc-gen-go-grpc, and printenv PATH returns /home/deckard/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/deckard/.dotnet/tools:/usr/lib/go-1.13:/home/deckard/go:/home/deckard/go/bin:/home/deckard/go/bin://home/deckard/go/bin
UPDATE: which protoc returns /usr/bin/protoc (tried to install it from precompiled binary to /home/deckard/.local/bin/protoc, didn't helped). In both cases protoc-gen-go-grpc --version returns protoc-gen-go-grpc 1.1.0. I also tried to copy everything from google.golang.org/protobuf to google.golang.org/protobuf, no result.

So I deleted github.com/golang/protobuf folder, and seems like google.golang.org/protobuf has started indexing, and everything just started working.

Related

protoc-gen-go does not execute on linux machine

I have installed protoc-gen-go and its in the bin direct and I have set the path to this as well. The problem is that when I run protoc-gen-go from the commandline it does not error, but nothing happens as well.
If I run the following command sudo protoc --go_out=. --go_opt=paths=source_relative --go-grpc_ths=source_relative helloworld/helloworld.proto I get the following error
protoc-gen-go: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--go_out: protoc-gen-go: Plugin failed with status code 1.
However protoc-gen-go is available in my /home/usrname/go/bin path and this bin path has been exported to my linux PATH variable. Not sure what is going wrong here. The protoc-gen-go has the following permissions
-rwxr-xr-x 1 usrname 9003065 Apr 16 11:16 protoc-gen-go

protoc-gen-go-grpc: program not found or is not executable [protoc-gen-go is in PATH]

I am trying to generate Go source code from .proto file through this command:
protoc greet/greetpb/greet.proto --go-grpc_out=plugins=grpc:.
and, this is the directory structure:
greet/greetpb/greet.proto
I have tried all the answers mentioned here
But, none of them seems to be working.
I have verified that protoc-gen-go is in PATH.
Still, I am getting this:
protoc-gen-go-grpc: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--go-grpc_out: protoc-gen-go-grpc: Plugin failed with status code 1.
Additional details:
Go Version: go version go1.14.6 darwin/amd64
protoc version: libprotoc 3.12.3
My .zshrc file:
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT:$GOPATH:$GOBIN

Error message:protoc-gen-go: Plugin failed with status code 1

This is not a duplicate question
First, I made sure I have the following configuration:
1 export GOPATH=/Users/chezixin/go
2 export GOBIN=/Users/chezixin/go/bin
3
4 export GO111MODULE=on
5 # 123
6 export GOPROXY=https://goproxy.cn
7
8
9 export PATH="$PATH:/Applications/Postgres.app/Contents/Versions/12/bin:/Users/chezixin/flutterSDK/flutter/bin:/usr/local/go/bin:$GOPATH:$GOBIN"
10
czxmac:~ chezixin$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:
/sbin:/Applications/VMwareFusion.app/Contents/Public:
/Applications/Postgres.app/Contents/Versions/latest/bin:
/Applications/Postgres.app/Contents/Versions/12/bin:
/Users/chezixin/flutterSDK/flutter/bin:/usr/local/go/bin:
/Users/chezixin/go:/Users/chezixin/go/bin':
/Users/chezixin/Go/bin:/Applications/Postgres.app/Contents/Versions/12/bin:
/Users/chezixin/flutterSDK/flutter/bin:
/usr/local/go/bin:/Users/chezixin/go:
/Users/chezixin/go/bin:/Users/chezixin/Go/bin
Already installed:
go get -u google.golang.org/grpc
look protoc:
czxmac:~ chezixin$ protoc --version
libprotoc 3.11.1
Protoc-gen-go is installed and exists in $ GOPATH/bin
go get -u github.com/golang/protobuf/protoc-gen-go
problem:
When I execute the following command
$ protoc --go_out=plugins=grpc:. *.proto
An error occurred:
protoc-gen-go: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--go_out: protoc-gen-go: Plugin failed with status code 1.
Where is the problem, please master guidance.
This issue is related with your PATH variable, please set it again.
I can see a typo of an extra trailing apostrophe(') in this line of PATH variable. /Users/chezixin/go:/Users/chezixin/go/bin':
Try updating it to
/Users/chezixin/go:/Users/chezixin/go/bin:
For anyone facing a similar issue, but it was not the case of an invalid PATH variable, I very much sympathize with you.
I realized that I had to install the compiler (again?) before it started working. I hadn't installed it before, but it appeared to already be downloaded. I guess I had to install it again or update it.
I personally was using betterproto, and I followed the instructions here to install it with the protoc plugin and try out their example.

Cannot build open-source project

I'd like to contribute to an OSS project built with go, but I'm having hard time compiling it. It looks as if I'm missing something obvious.
I think the problem is related to how go is installed on my computer, and not to the project itself, thus I'm posting it here on StackOverflow, instead of project's "Issues" section.
Below is what I'm doing.
I've installed go using homebrew:
$ brew install go
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
libebml
==> Downloading https://homebrew.bintray.com/bottles/go-1.8.3.sierra.bottle.tar.gz
Already downloaded: /Users/gmile/Library/Caches/Homebrew/go-1.8.3.sierra.bottle.tar.gz
==> Pouring go-1.8.3.sierra.bottle.tar.gz
==> Caveats
A valid GOPATH is required to use the `go get` command.
If $GOPATH is not specified, $HOME/go will be used by default:
https://golang.org/doc/code.html#GOPATH
You may wish to add the GOROOT-based install location to your PATH:
export PATH=$PATH:/usr/local/opt/go/libexec/bin
==> Summary
🍺 /usr/local/Cellar/go/1.8.3: 7,035 files, 282.0MB
$
Then I cloned the repo:
$ hub clone lucapette/fakedata
I ran make setup (per instruction), which at first did not complete successfully:
$ make setup
go get -u github.com/alecthomas/gometalinter
gometalinter --install
make: gometalinter: No such file or directory
make: *** [setup] Error 1
$
I figured that is because gometalinter is nowhere in my $PATH, so have added it (I'm using fish-shell):
$ set fish_user_paths /Users/gmile/go/bin
running make setup seem to have succeeded now. This is the output:
$ make setup
go get -u github.com/alecthomas/gometalinter
gometalinter --install
Installing:
aligncheck
deadcode
dupl
errcheck
gas
goconst
gocyclo
goimports
golint
gosimple
gotype
ineffassign
interfacer
lll
megacheck
misspell
safesql
staticcheck
structcheck
unconvert
unparam
unused
varcheck
$
Running make build fails:
$ make build
go build
main.go:11:2: cannot find package"github.com/lucapette/fakedata/pkg/fakedata" in any of:
/usr/local/Cellar/go/1.8.3/libexec/src/github.com/lucapette/fakedata/pkg/fakedata (from $GOROOT)
/Users/gmile/go/src/github.com/lucapette/fakedata/pkg/fakedata (from $GOPATH)
main.go:12:2: cannot find package "github.com/spf13/pflag" in any of:
/usr/local/Cellar/go/1.8.3/libexec/src/github.com/spf13/pflag (from $GOROOT)
/Users/gmile/go/src/github.com/spf13/pflag (from $GOPATH)
make: *** [build] Error 1
$
So either Contributing guideline is incomplete, or I'm missing something obvious about installing and managing go packages.
Your path when cloning the source must be on the golang PATH like :
/home/gujarat/golang/src/github.com/lucapette/fakedata
as you can see my Path to golang path is : /home/gujarat/golang/.
You can also print your golang path in your terminal by entering : $GOPATH.
And the git clone should be in the following the exact as above path : src/github.com/lucapette/.
cd $GOPATH/src/github.com/
mkdir lucaptte
cd lucapette
git clone https://github.com/lucapette/fakedata.git
When you are running the make command which trigger go build this command will look the $GOPATH and your $GOROOT folder.
Your go source should in your gopath - here it is Users/gmile/src. Use go get to fetch the pkg you want to work on instead and it should work.

Getting Unknown flag: -v when i run protoc -version in my ubuntu

I'm getting the following message when i run protoc -version in my ubuntu terminal.
Unknown flag: -v
Earlier to this, I had got the following error when I ran protoc -version. I found a solution through google and ran "sudo ldconfig /usr/local/lib". After running that, I'm getting the Unknown flag message as mentioned above. Can anyone help me to resolve this? Thanks in advance.
protoc: error while loading shared libraries: libprotoc.so.9: cannot open shared object file: No such file or directory
Long flags require two dashes. Try:
protoc --version
(Common Unix convention says that if you write -abc (with one dash), it means the same thing as -a -b -c, which is why you get the error saying that there is no flag -v. Admittedly, there are a lot of Unix programs that don't follow this rule, but protoc does follow it.)

Resources