I am installing cloud foundry command line in Raspberry P2 running raspbian Jessie, I have tried ways using the Installer and the binary Installation, I have tried to force the architecture amrhf. The result I get when running the cf command on the terminal is "/usr/bin/cf: cannot execute binary file: Exec format error" I have tried to change the mode with this command "chmod +x /usr/bin/cf" the error is still there.
1 Answer
As @Billp3rd says, it seems that the binary (/usr/bin/cf
) is not compiled for ARM architecture.
You need to compile it from source. To do so:
Install go
on your raspi, because cf
is developed in go
Do not use apt-get install golang
. If it has been installed from repo, remove it by apt-get remove golang; apt-get autoremove
.
The version 1.3.1
in the repo has known bugs. Instead download arm distribution of the latest version
which is 1.7.1 for now.
root@mypi:~# cd /opt
root@mypi:/opt# wget https://storage.googleapis.com/golang/go1.7.1.linux-armv6l.tar.gz
root@mypi:/opt# tar xvf go1.7.1.linux-armv6l.tar.gz
root@mypi:/opt# cd ~
The archive is extracted to /opt/go
.
Create a folder for GOPATH
. I choose /root/mygopath
.
root@mypi:~# mkdir /root/mygopath
Set variables required for go
root@mypi:~# export GOROOT=/opt/go
root@mypi:~# export GOPATH=/root/mygopath
Download and build cf-cli
. This process takes some time.
root@mypi:~# /opt/go/bin/go get code.cloudfoundry.org/cli
In normal circumtances, the cli
binary should be created under /root/mygopath/bin/
.
Copy or move cli
binary compiled for ARM. I prefer to put it under /opt/cf/
.
root@mypi:~# mkdir /opt/cf
root@mypi:~# cp /root/mygopath/bin/cli /opt/cf/
Here is output of cli
command on ARM.
root@mypi:~# /opt/cf/cli
/opt/cf/cli version BUILT_FROM_SOURCE-BUILT_AT_UNKNOWN_TIME, Cloud Foundry command line tool
Usage: /opt/cf/cli [global options] command [arguments...] [command options]
Before getting started:
config login,l target,t
help,h logout,lo
Application lifecycle:
apps,a logs set-env,se
push,p ssh create-app-manifest
start,st app
stop,sp env,e
restart,rs scale
restage,rg events
-
Thanks @vaha, I have tried to follow your instructions, but now once I run this command "./bin/build" then I get this Generating Binary... main.go:10:2:– MasaCommented Oct 19, 2016 at 9:39
-
Generating Binary... main.go:10:2: cannot find package "code.cloudfoundry.org/cli/cf/cmd" in any of: /usr/lib/go/src/pkg/code.cloudfoundry.org/cli/cf/cmd (from $GOROOT) /usr/local/sbin/src/code.cloudfoundry.org/cli/cf/cmd (from $GOPATH) /usr/local/bin/src/code.cloudfoundry.org/cli/cf/cmd /usr/sbin/src/code.cloudfoundry.org/cli/cf/cmd /usr/bin/src/code.cloudfoundry.org/cli/cf/cmd /sbin/src/code.cloudfoundry.org/cli/cf/cmd /bin/src/code.cloudfoundry.org/cli/cf/cmd /usr/local/games/src/code.cloudfoundry.org/cli/cf/cmd /usr/games/src/code.cloudfoundry.org/cli/cf/cmd– MasaCommented Oct 19, 2016 at 9:40
-
Those errors are caused by wrong GOPATH value. You should set GOPATH to where you cloned the source in. At the current step, you should look for GO specific solutions in GO related sites from GO experts =).– vahaCommented Oct 19, 2016 at 9:46
-
I think I found how to compile. I will test when I access to my raspberry.– vahaCommented Oct 19, 2016 at 10:49
-
file /usr/bin/cf
should settle that one way or the other.