Cannot build open-source project - macos

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.

Related

Windows pkg_config failed: `"pkg-config" "--libs" "--cflags" "dbus-1" "dbus-1 >= 1.6"` did not exit successfully

I'm attempting to compile a Rust app on windows, and I've hit a problem I don't know how to solve. Running cargo build produces:
--- stderr
pkg_config failed: `"pkg-config" "--libs" "--cflags" "dbus-1" "dbus-1 >= 1.6"` did not exit successfully: exit code: 1
--- stderr
Package dbus-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dbus-1' found
Package dbus-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dbus-1' found
One possible solution is to check whether packages
'libdbus-1-dev' and 'pkg-config' are installed:
On Ubuntu:
sudo apt install libdbus-1-dev pkg-config
On Fedora:
sudo dnf install dbus-devel pkgconf-pkg-config
Can this advice (to install libdbus-1-dev) be adjusted for Windows? What is the general process for such, in case I hit a similar problem on another package after resolving this one?

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

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.

updating to svn 1.9.4 via command line in mac

I am using SVN against my will. The current team I work with uses it for version control and they are not always available to help me. I am just trying to go from SVN Version 1.8.13 to the latest 1.9.4
I have download it and I have ran this command too
curl -o subversion-latest.tar.gz http://apache.mirrors.tds.net/subversion/subversion-1.9.4.tar.gz
tar -xvf subversion-latest.tar.gz
I have combined these two different tutorials with no luck.
svn update version
stackover flow issue
I am STUCK at with the configure part..
mymac ~/Downloads/subversion-1.9.4/serf
$ ./configure
-bash: ./configure: No such file or directory
mymac ~/Downloads/subversion-1.9.4/serf
UPDATE
I exited out of serf path and on
`mymac ~/Downloads/subversion-1.9.4` file path i ran the `./configure` My command line ran a bunch of "checks"
configure: Configuring Subversion 1.9.4
configure: creating config.nice checking for gcc...
gcc checking whether the C compiler works...
yes but eventually shot an error at the end...
configure: error: failed to recognize APR_INT64_T_FMT on this platform
mymac ~/Downloads/subversion-1.9.4
I have the latest version of XCode..
UPDATE2 tried neon, again
mymac ~/Downloads/subversion-1.9.4
$ sh get-deps.sh neon
Local directory 'serf' already exists; the downloaded copy won't be used
Local directory 'apr' already exists; the downloaded copy won't be used
Local directory 'apr-util' already exists; the downloaded copy won't be used
get-deps.sh: line 151: get_neon: command not found
Usage: get-deps.sh
Usage: get-deps.sh [ apr | serf | zlib | sqlite | gmock ] ...
mymac ~/Downloads/subversion-1.9.4
$ cd neon
-bash: cd: neon: No such file or directory
UPDATE 3
ran this command first ..
mymac ~/Downloads/subversion-1.9.4
$ ./configure --prefix=/usr/local --with-serf=/usr/local/serf
configure: Configuring Subversion 1.9.4
configure: creating config.nice
checking for gcc... gcc
checking whether the C compiler works... yes
I guess I should install a new version of serf?
checking was serf enabled... no
An appropriate version of serf could not be found, so libsvn_ra_serf
will not be built. If you want to build libsvn_ra_serf, please
install serf 1.3.4 or newer.
configure: error: Serf was explicitly enabled but an appropriate version was not found.
I have no clue where to go from here and how to get around it. I already figure out that neon is no longer supported and I am using serf Can someone offer a different way to go about this? Please? Thanks!
Consider using Brew or MacPorts, if possible. Then this can be as simple as:
brew install svn
If you really must install from source,
it might not be as complicated as the steps you described so far.
Try these much simpler steps exactly:
cd /tmp
curl -o subversion-latest.tar.gz http://apache.mirrors.tds.net/subversion/subversion-1.9.4.tar.gz
tar -xvf subversion-latest.tar.gz
cd subversion-1.9.4
./configure --prefix=/tmp/local
make
make install
This will (hopefully) build Subversion and install it into /tmp/local. Test with this command:
/tmp/local/bin/svn --version
If the output looks good, then repeat from the start, but use a different value for --prefix, as appropriate in your environment.
(I tried, and this worked well for me, right now, btw.)
Maybe it's not so simple. In that case please update your question with the output where you get stuck.

Why is /var/lib/dpkg/status missing on a BitBake-generated OS?

I have installed apt onto a system built by BitBake by adding the apt package to the IMAGE_INSTALL variable in my recipe.
apt-get and apt-cache now execute on the built system, but if I try to do anything useful with them (such as apt-get update or apt-cache search), I get the following error:
E: Could not open file /var/lib/dpkg/status - open (2: No such file or directory)
E: The package lists or status file could not be parsed or opened
After some preliminary searching, I found this exchange on the Yocto Project mailing list:
Hi,
I have some requirement with apt-get in yocto genearted rootfs.
I built the yocto source code with enabling the apt package.
But after booting the image on my machine and run the "apt-get" command for installing some package it gives the following error.
Could not open the file /var/lib/dpkg/status open(2: no such a file or directory).
The package lists or status files could not be parsed or opened.
This error is because you need to add package-management to EXTRA_IMAGE_FEATURES in local.conf,
PACKAGE_CLASSES ?= "package_deb"
EXTRA_IMAGE_FEATURES = "debug-tweaks package-management"
I've added package-management but don't see any different output.
After a touch /var/lib/dpkg/status, apt-get update returns the following:
Reading package lists...Done
How can I get apt into a functioning state through the use of BitBake metadata?
I have found a similar thread from the NXP website.
You would need to set up your own web server and provide all those packages and add the server URL to the source list. SourceList
In addition, you have to update the package manifest by running bitbake package-index and add PACKAGE_CLASSES ?= " package_deb" to conf/local.conf
I have successfully set up OPKG before. The steps are similar, you can find it here

Install external package in Google Go

I was trying to install external packages in GO language. I've found many external packages at http://godashboard.appspot.com/package.
I am working on windows system.
I tried this command to install go-router package.
goinstall go-router.googlecode.com/svn/trunk
This resulted in following error....
C:\cygwin\bin\bash.exe: === cd c:\go\src\pkg\go-router.googlecode.com\svn\trunk;
bash gomake -f- install
/cygdrive/c/go/bin/gomake: line 3: exec: make: not found
--- exit status 127
goinstall: go-router.googlecode.com/svn/trunk: install: running bash: exit status 127
I am unable to find out the reason for the error and the meaning of status code. I've read the goinstall command description but no luck..
It seems make command is missing. Make sure it's installed and that PATH variable is defined correctly.

Resources