Fixing docker-credential-gcloud not installed or not available in PATH – macOS version

So, you are trying to deploy a simple solution with multiple containers using docker-compose, and when you try to build them, you get the following error:

docker.credentials.errors.InitializationError: docker-credential-gcloud not installed or not available in PATH
[9809] Failed to execute script docker-compose

Not going into the merit of the discussion of why docker-compose needs one of the Google Cloud SDK components installed, here is the solution to solve this problem, in your macOS Catalina (version 10.15.6 (19G2021)).

But first, let’ me list the version of some tools in my environment:

% docker --version 
Docker version 19.03.12, build 48a66213fe
% docker-compose --version 
docker-compose version 1.26.2, build eefe0d31
% brew --version
Homebrew 2.4.16
Homebrew/homebrew-core (git revision 6195c; last commit 2020-09-01)
% python -V
Python 2.7.16
% python3 -V
Python 3.8.1

docker-credential-gcloud is one of the components available in the Google Cloud SDK (gcloud), so basically to solve the error you have to install them. Download the latest version of the SDK from here. Ignore the steps described there, and focus only on downloading the tarball package (step 3).

Once downloaded, extract it in a place to keep the files persistent. Let’s suppose the path ~/Projects/. Then, execute the following steps:

% cd ~/Projects/google-cloud-sdk/
% ./install.sh

Follow the “installation” process as you wish, but it’s recommended to answer YES to update the $PATH and enable shell command completion.  After completing the configuration process, open a new terminal (or execute ‘source ~/.zshrc’ or your shell rc file) and execute:

% gcloud components install docker-credential-gcr

At the end of this process, when you try to build or execute your docker-compose configuration you will be able to have your containers running.

Criando um README para seu Perfil do GitHub.

en_US readers: Since there are a lot of articles in English about this
topic, I recommend you to go here to see more information.

Aqueles já acostumados a desenvolver software devem saber que um bom projeto deve conter alguns arquivos padrão. Alguns desses arquivos descrevem a licença do projeto (LICENSE) ou a forma de contribuição (CONTRIBUTING). Mas acredito que o mais importante de todos eles é aquele arquivo que descreve o projeto como um todo – o LEIAME ou README. Esse arquivo é utilizado para descrever o projeto em mais detalhes ou adicionar documentação para os usuários ou desenvolvedores como como utilizá-lo, compilá-lo ou testá-lo.

Se você utiliza o GitHub para o controle de versão do seu projeto, ele já te ajuda no momento da criação do repositório a gerar um arquivo README.md inicial. E já que você utiliza o GitHub, deve muito bem saber que ele te fornece um perfil de usuário, onde você pode listar seus repositórios principais e, inclusive, visualizar estatísticas de suas contribuições. Mas uma funcionalidade que muitos não conhecem do perfil do GitHub é a do README pessoal.

Pois bem! O GitHub disponibiliza uma forma de você criar um README para seu perfil, que será usado como cabeçalho na sua página de perfil. A seguir, mostro o passo-a-passo de como criar um README de perfil. É tudo muito simples.

  1. Crie um novo repositório com o mesmo nome do seu nome de usuário (username) do GitHub. Isso ativará uma mensagem em verde descrevendo que você achou um segredo. Atenção aqui: o nome do repositório deve ser o mesmo do nome de usuário. Do contrário, a funcionalidade não funcionará.
  2. Selecione a opção para tornar seu repositório Público (Public).
  3. Habilite a opção de inicializar o repositório com um README (Initialize this repository with a README).
  4. Clique no botão para criar o repositório (Create repository).

Isso fará com que o GitHub crie um repositório com um arquivo README.md inicial.

Após isso, você pode editar o arquivo da maneira que você quiser. Você pode, como qualquer outro projeto, clonar o repositório no seu dispositivo local de desenvolvimento ou editar o arquivo na própria interface Web do GitHub.  Para isso, você tem duas opções: 1) clicar no botão de editar o README (Edit README) que aparecerá em uma caixa verde do canto superior direito, ou 2) clicar no ícone do lápis (ou caneta) que aparece na visualização do REAMDE.md que o GitHub disponibiliza. Ambas as opções abrem o editor de texto do GitHub no seu navegador e então basta deixar a criatividade rolar.

Sem idéias de como incrementar o seu arquivo? Você pode utilizar o meu repositório como referência uma vez que o disponibilizei sob a licença MIT, mas o usuário abhisheknaiidu criou um repositório com diversas idéias e diferentes ferramentas para incrementar seu arquivo: https://github.com/abhisheknaiidu/awesome-github-profile-readme

Este é o resultado final da primeira versão (sim, pois essa é sua vitrine digital, como um CV) do meu README:

Legal essa funcionalidade, não? Se você gostou deste artigo, compartilhe com seus amigos via Twitter ou Facebook, e se você também criou o seu README no GitHub, não deixei de comentar com o seu link de perfil abaixo.

Installing Go on macOS

For quite some time I want to start learning and playing with the Go programming language but have never had the opportunity, time and/or patience for that. But now, I think it’s time to do that.

Better Late Than Never Bltn GIF by NBC - Find & Share on GIPHY

Go, or golang, “is an open-source programming language that makes it easy to build simple, reliable, and efficient software.” It was designed by Google in 2007 and publicly announced in November 2009. It is syntactically similar to the C programming language, but with some improvements, like memory safety, garbage collection, and structural typing. If you want to know more about the history and features of it, I recommend you read the Wikipedia article about it.

Now, let’s install it on macOS.

Seth Meyers Let'S Go GIF by Late Night with Seth Meyers - Find & Share on GIPHY

The best way to have Go working on a macOS is by installing the latest stable package installer from https://golang.org/dl/. Once downloaded, just open the go<version>.darwin-amd64.pkg file and follow the process:

  1. Click on ‘Continue’
  2. Click on ‘Install’
  3. Wait for the installation…
  4. Click on ‘Close’

Voilà!!! You have the Go tools installed on your system. The package installs the Go distribution to /usr/local/go.The package should put the /usr/local/go/bin directory in your PATH environment variable.

Let’s check it. Open a (new) terminal and type:

$ go version
go version go1.14.4 darwin/amd64
$

Perfect! Now with Go properly installed and configured you can build your Hello World to program. Create a file named hello_world.go with the content:

package main

import "fmt"

func main() {
    fmt.Printf("Hello, GO World\n")
}

Then, build it with the Go tools, with the command:

$ go build hello_world.go

This will compile and build an executable called hello_world. Now, just execute it to see the output:

$ ./hello_world
Hello, GO World
$

 

Parks And Recreation Reaction GIF - Find & Share on GIPHY

Amazing!!! You have the Go programming language installed and configured now.

Enjoy it and have fun!

Installing Groovy on macOS

One of the new tasks I am executing in my new job is to write scripts in Groovy. Apache Groovy is, as Wikipedia well defines it, a dynamic object-oriented programming language with features similar to those of Python and Ruby, but for the Java platform. It can be used as a scripting language, is dynamically compiled to Java virtual machine (JVM) bytecode, and interoperates with other Java code and libraries.

The best way to have Groovy working on a macOS X machine is by installing the SDKMAN (Software Development Kit Manager). It manages the installation of Groovy on any Bash platform (then, not only for macOS boxes) as simple as you can slice a piece of cake.

To install the SDKMAN, open your terminal and follow this process:

$ curl -s get.sdkman.io | bash
                                       Now attempting installation...


Looking for a previous installation of SDKMAN...
Looking for unzip...
Looking for zip...
Looking for curl...
Looking for sed...
Installing SDKMAN scripts...
Create distribution directories...
Getting available candidates...
Prime the config file...
Download script archive...
############################################################## 100.0%
Extract script archive...
Install scripts...
Set version to 5.6.2+294 ...
Attempt update of login bash profile on OSX...
Added sdkman init snippet to /Users/pvital/.bash_profile
Attempt update of zsh profile...
Updated existing /Users/pvital/.zshrc


All done!


Please open a new terminal, or run the following in the existing one:

    source "/Users/pvital/.sdkman/bin/sdkman-init.sh"

Then issue the following command:

    sdk help

Enjoy!!!
$ source "/Users/pvital/.sdkman/bin/sdkman-init.sh”
$ sdk help
==== BROADCAST ======================================================
* 12/03/18: Groovyserv 1.2.0 released on SDKMAN! #groovyserv
* 07/03/18: Grails 3.3.3 released on SDKMAN! #grailsfw
* 06/03/18: Groovy 2.6.0-alpha-3 released on SDKMAN! #groovylang
=====================================================================

Usage: sdk <command> [candidate] [version]
       sdk offline <enable|disable>

   commands:
       install   or i    <candidate> [version]
       uninstall or rm   <candidate> <version>
       list      or ls   [candidate]
       use       or u    <candidate> [version]
       default   or d    <candidate> [version]
       current   or c    [candidate]
       upgrade   or ug   [candidate]
       version   or v
       broadcast or b
       help      or h
       offline           [enable|disable]
       selfupdate        [force]
       update
       flush             <candidates|broadcast|archives|temp>

   candidate  :  the SDK to install: groovy, scala, grails, gradle, 
                 kotlin, etc.
                 use list command for comprehensive list of candidates
                 eg: $ sdk list

   version    :  where optional, defaults to latest stable if not 
                 provided
                 eg: $ sdk install groovy
$

At this point you have SDKMAN installed. Now you can use it to install Groovy:

$ sdk install groovy

Downloading: groovy 2.4.14

In progress...

############################################################## 100.0%

Installing: groovy 2.4.14
Done installing!



Setting groovy 2.4.14 as default.
$

Great! You have Groovy installed and configured on your machine. Let’s check it:

$ groovy -version
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
groovy: JAVA_HOME is not defined correctly, can not execute: java
$

OOOPS!!!

As mentioned before, Groovy is a programming language for the Java platform. So, looks like it is necessary to have Java installed before you be able to execute any Groovy script. To install the latest JDK version on your macOS, follow these steps:

  1. Download the jdk-8u<version>-macosx-x64.dmg file from here;
  2. Open the downloaded .dmg file;
  3. Double-click the .pkg file to launch the installer;
  4. Follow the installation process;
  5. After the installation finishes, set the JAVA_HOME environment variable by adding the following line on your ˜/.bash_profile file:
export JAVA_HOME=$(/usr/libexec/java_home)

Source your ˜/.bash_profile file and check if the JAVA_HOME variable and Java are configured correctly:

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
$ java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
$

Perfect! Now with Java properly installed and configured you can check Groovy installation:

$ groovy -version
Groovy Version: 2.4.14 JVM: 1.8.0_162 Vendor: Oracle Corporation OS: Mac OS X
$

Voilà!!! You have Groovy installed and configured now.