Composer: Cannot create cache directory /home/webadmin/.composer/cache/repo/https-

When working with Drupal 8 and Ubuntu 18.04, you might encounter this Error: Cannot create cache directory /home/webadmin/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache


Solution: sudo chown -R $USER $HOME/.composer