Error while running make command using Fabric 1.0.6 after all the 15 steps - makefile

I am installing fabric in a custom path $HOME//gopath/src/github.com/hyperledger/fabric using the make command but after installing all the 15 steps, I am getting the following error
Step 15/15 : LABEL org.hyperledger.fabric.version=1.0.2 org.hyperledger.fabric.base.version=0.3.2
---> Running in ed05a67810db
Removing intermediate container ed05a67810db
---> 99b4b0b28957
Successfully built 99b4b0b28957
Successfully tagged hyperledger/fabric-javaenv:latest
docker tag hyperledger/fabric-javaenv hyperledger/fabric-javaenv:x86_64-1.0.2
build/bin/peer
CGO_CFLAGS=" " GOBIN=/root/gopath/src/github.com/hyperledger/fabric/build/bin go install -tags "" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.2 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.2 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/peer
go build github.com/hyperledger/fabric/vendor/github.com/miekg/pkcs11: invalid flag in #cgo LDFLAGS: -Wl,--no-as-needed
Makefile:227: recipe for target 'build/bin/peer' failed
make: *** [build/bin/peer] Error 1
Docker version 17.12.0-ce, build c97c6d6
docker-compose version 1.18.0, build 8dd22a9
go version go1.9.4 linux/amd64
OS : Ubuntu 16.04
I have set the following path also
$ mkdir $HOME/gopath
$ export GOPATH=$HOME/gopath
$ export GOROOT=$HOME/go
$ export PATH=$PATH:$GOROOT/bin
Jira Link: https://jira.hyperledger.org/browse/FAB-2218 which I have already done

It is a known issue in go 1.9.4:
https://github.com/golang/go/issues/23739
While go people are fixing it, you can manually whitelist the flags before starting make:
$ export CGO_LDFLAGS_ALLOW='-Wl,--no-as-needed'
$ make
Alternatively you can just downgrade to go 1.9.3

as far as I know you don't need to build the fabric itself.
You just need to have sources in the gopath, as your chaincode will need this, when you are building your chaincode for the blockchain itself.
In addition you will probably also need to install the fabric-ca for your chaincode to build successfully, if you use the certificate-stuff.
This is sufficient to check if you installed fabric correctly:
cd $GOPATH/src/github.com/hyperledger/fabric
make unit-test
Keep going if this works.
I found this confusing at first as well ;)

I'd assume you switch to golang 1.9.4 or greater hence I belive this actually related to following issue, to solve it you need to update vendor dependencies:
govendor fetch github.com/hyperledger/fabric/vendor/github.com/miekg/pkcs11
Next continue to build binaries and run tests.

Related

Failure: plugin grpc-gateway: could not find protoc plugin for name grpc-gateway -

while genrating Prot buff using "buf generate"
i am getting below error :
Failure: plugin grpc-gateway: could not find protoc plugin for name grpc-gateway - please make sure protoc-gen-grpc-gateway is installed and present on your $PATH
i have tried installtion of
"go install google.golang.org/grpc/cmd/protoc-gen-go-grpc#latest; "
$ go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway#latest
$ go install google.golang.org/protobuf/cmd/protoc-gen-go#latest
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc#latest
then check for your path , if its not set then use below command :
PATH="${PATH}:${HOME}/go/bin"
The error is specifically for protoc-genc-grpc-gateway which is distinct from proto-gen-go-grpc.
See the Installation instructions that include protoc-gen-grpc-gateway.
You will also need that the plugin is in your host's PATH. On Linux you can which protoc-gen-grpc-gateway to confirm this after installation.

Golang linter issues 'context loading failed: no go files to analyze'

We are using
golangci-lint version 1.40.1 together with
golang version 1.16.4
in our project for linting our Golang code.
Until now, what we did is running this bash script (from the root
directory of our repository):
if ! [ -x "$(command -v golangci-lint)" ]; then
echo "Fetching linter..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint
go mod tidy
fi
golangci-lint run --build-tags="unit contract container"
With some recent updates of Golang and golangci-lint, we suddenly face this error message:
ERRO Running error: context loading failed: no go files to analyze
There is a lengthy post on GitHub regarding this issue but the only useful suggestion there is to turn off the GO111MODULE env variable. When I run the linter with GO111MODULE turned off like
GO111MODULE=off golangci-lint run --build-tags="unit contract container"
the upper error message disappears but instead I am getting lots of false linting errors like:
api/router.go:152:5: undeclared name: `PermissionUpdatePackage` (typecheck)
PermissionUpdatePackage,
^
My go environment looks like this:
GO111MODULE=on
GOPATH=/Users/USER/workspace/go
GOROOT=/usr/local/opt/go/libexec
GOPRIVATE=*.CUSTOMER.com
GOSS_PATH=/usr/local/bin/goss
I tried to install the linter via go get... as well as go install ... and finally brew install golangci-lint which seems to be the recommended way following this documentation.
Running a go get ./... in the root of the project eventually solved the issues. In between we ran the following commands that probably cleared some (module?) caches that might have caused trouble as well:
golangci-lint cache clean && go clean -modcache -cache -i
golangci-lint run -v --timeout=5s
The error message
ERRO Running error: context loading failed: failed to load packages: timed out to load packages: context deadline exceeded
in the latter command pointed us to this GitHub post that made me try out go get ./...
For installing the linter (with a specified version), we ended up with this script:
linter_version='1.40.1'
if ! [ -x "$(command -v golangci-lint)" ]; then
echo "Fetching linter..."
# we cannot install linter in the project directory, otherwise we get dependency errors
# hence, temporarily jump into the /tmp directory
pushd /tmp > /dev/null
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint#v"${linter_version}" 2>&1
popd >/dev/null
fi

Unable to Install Go-Ipfs from source

I'm trying to Build IPFS from Source on windows 10.
Previously i installed it from source.It was working fine. But i needed the latest source so i started again from the scratch. because i edited some parts in the source.
I followed instructions on https://github.com/ipfs/go-ipfs/blob/master/docs/windows.md.
I received following error on executing following commands.
code
cd %GOPATH%\src\github.com\ipfs\go-ipfs
make install
Error
go version go1.12.6 windows/amd64
bin/check_go_version 1.12
go install -asmflags=all=-trimpath="D:\GO_WORKSPACE" -gcflags=all=-trimpath="D:\GO_WORKSPACE" -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=810cb607e-dirty" ./cmd/ipfs
# github.com/ipfs/go-ipfs/plugin/loader
plugin\loader\preload.go:11:2: undefined: pluginipldgit
plugin\loader\preload.go:12:2: undefined: pluginbadgerds
plugin\loader\preload.go:13:2: undefined: pluginflatfs
plugin\loader\preload.go:14:2: undefined: pluginlevelds
make: *** [cmd/ipfs/Rules.mk:37: cmd/ipfs-install] Error 2
I tried Adding this plugins in to preload.go file under src\github.com\ipfs\go-ipfs\plugin\loader directory.
exisiting code on preload.go.
import (
"github.com/ipfs/go-ipfs/plugin"
)
i added after the issue
import (
"github.com/ipfs/go-ipfs/plugin"
pluginipldgit "github.com/ipfs/go-ipfs/plugin/plugins/git"
pluginbadgerds "github.com/ipfs/go-ipfs/plugin/plugins/git"
pluginflatfs "github.com/ipfs/go-ipfs/plugin/plugins/git"
pluginlevelds "github.com/ipfs/go-ipfs/plugin/plugins/git"
)
so after i added this lines result is success.
Executed command
make install
Result
go version go1.12.6 windows/amd64
bin/check_go_version 1.12
go install -asmflags=all=-trimpath="D:\GO_WORKSPACE" -gcflags=all=-trimpath="D:\GO_WORKSPACE" -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=810cb607e-dirty" ./cmd/ipfs
Then i tried to start the ipfs using following command
ipfs daemon
Error
Initializing daemon...
go-ipfs version: 0.4.22-dev-810cb607e-dirty
Repo version: 7
System version: amd64/windows
Golang version: go1.12.6
Error: unknown datastore type: flatfs
Can someone help me configure the IPFS from source.
Thanks in advance.
I solved this problem by following method. not sure this will be a good solution or not. any way i could solve the issue.
I'm posting this as a answer. so it will be useful to everyone who has the same issue.
1) Deleted go-ipfs folder inside the "%GO_WORKSPACE% / .... / ipfs" folder.
2) Git clone the go ipfs repo manually on the same location.
3) go inside go-ipfs folder.
4) execute install command.
make install
Done on Windows.
Save IPFS (kubo) to some folder inside %GOPATH% (I cloned https://github.com/ipfs/kubo) to folder %GOPATH%\kubo
Important cd %GOPATH%\kubo\cmd\ipfs\
go install
ipfs.exe was placed in %GOPATH%\bin
I launched it as daemon - works.
BTW: GOROOT is defined and path to go is included in PATH

How can I fix the following Google Cloud Platform deployment error? [Error 2]

I'm trying to deploy my web-app to Google Cloud Platform, and I got an error while deploying. I understand that last package (go-sqlite3) needs gcc compiler, and Google Cloud WM has it:
$which gcc
/usr/bin/gcc
but it won't work
Step 3 : RUN go-wrapper install -tags appenginevm
---> Running in b0f03024342d
+ exec go install -v -tags appenginevm
github.com/mattn/go-colorable
github.com/mattn/go-isatty
github.com/labstack/gommon/color
github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
github.com/valyala/fasttemplate
github.com/labstack/gommon/log
golang.org/x/crypto/acme
golang.org/x/crypto/acme/autocert
github.com/labstack/echo
golang.org/x/net/context
github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
exec: "gcc": executable file not found in $PATH
The command '/bin/sh -c go-wrapper install -tags appenginevm' returned a non-zero code: 2
ERROR
ERROR: build step "gcr.io/cloud-builders/docker#sha256:926dc1a14e6f7eb5b3462b5c1d491aa6c73090291167ac2bf181c026b05f19da" failed: exit status 2
You have to make your path correct by following command on your shell.
PATH=/usr/bin:$PATH

Unable to change GO version in PhotonOS

I have deployed PhotonOS using directions from photon and VIC configuration, while running command docker run -v $(pwd):/go/src/github.com/vmware/vic \-w /go/src/github.com/vmware/vic golang:1.6 make all
an Error appears:
Please install go1.7 (found: go version go1.6.3 linux/amd64)
Makefile:152: recipe for target 'goversion' failed
make: *** [goversion] Error 1
`
to solve it I have tried to update
go1.6.3 to go1.7 using solution - changeing go version manually
after steps go version is showing go1.4.2, but the previous error still complains on go version 1.6.3.
Also, I have tried to install "gvm" using bash < <(curl -s -S -L https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer) , whenever I try to call gvm install go1.7 it brings
-bash: gvm: command not found
whenever I retry running gvm-installer it says
ERROR: Already installed!
Any help is highly appreciated!!
use :
docker run -v $(pwd):/go/src/github.com/vmware/vic \-w /go/src/github.com/vmware/vic golang:1.7 make all
command instead, that will work on PhotonOS

Resources