How to Install Doctl on Raspberry Pi OS

Let us install Doctl, the Digital Ocean Client on Raspberry Pi OS.

Photo credit – Gavin Allanwood @ unsplash.com

At the time of writing this post, an official build was not available for arm, so we will be installing the development version of doctl.

Prerequisite

To install the dev version of doctl, golang is required. Sometimes, doctl will not work with the latest version of golang. Installing the previous stable version seem to work. At the time of writing this post, go 1.15.x was the latest version available, but go 1.14.x was the one that worked with doctl. So, If latest golang did not work for you, try downgrading to the previous version.

Raspberry Pi OS Architecture

If you do not know your OS’s current architecture version, execute the following command.

uname -m

A response of ‘armv7l’ means that the OS is 32 bit and ‘aarch64’ means the OS is 64 bit.

Installing Golang

To install 32 bit executable, issue following command in the terminal.

curl -LO https://golang.org/dl/go1.14.13.linux-armv6l.tar.gz

To install 64 bit executable, issue following command in the terminal.

curl -LO https://golang.org/dl/go1.14.13.linux-arm64.tar.gz

Extract the executable to usr/local

sudo tar -C /usr/local -xzf go*.tar.gz

Add golang to the system path

cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF

Check the installed golang version

go version
golang verion 14 screenshot

Installing Doctl

Execute following command to install doctl.

go get github.com/digitalocean/doctl/cmd/doctl

It should take a couple of minutes to complete.

To check doctl version

doctl version
doctl version screenshot

We did install development version, so ignore the message asking to install the latest release.

Now initialise doctl with access token

doctl auth init
doctl auth screenshot

Enable Autocomplete

To enable autocomplete, execute following command.

cat >> ~/.profile << 'EOF'
source <(doctl completion bash)
EOF

then source the .profile using,

source ~/.profile

Autocomplete should now be available on raspberry pi. Clicking on tab with half typed command should autocomplete or display all available options.

doctl autocomplete screenshot

We have successfully installed Doctl and enabled autocomplete on Raspberry Pi OS. That’s it !