Composer is not supposed to be ran as sudo / root, but at the same using the global (or -g) argument might give us permission errors.
To fix this, we need to change ownership of the ~/.composer directory to the current user:
$ sudo chown -R $USER:$USER ~/.composer