.config/gh: permission denied

I’m trying to login in a GitHub, but I can’t neither web browser neither authentication token.
How can I fix that?

> (carmen) carmen_tur@Air-de-Carmen-2 ~ %
> (carmen) carmen_tur@Air-de-Carmen-2 ~ % gh auth login
> ? What account do you want to log into? GitHub.com
> ? What is your preferred protocol for Git operations? HTTPS
> ? Authenticate Git with your GitHub credentials? Yes
> ? How would you like to authenticate GitHub CLI? Login with a web browser
> 
> ! First copy your one-time code: 8B72-2968
> - Press Enter to open github.com in your browser...
> failed to authenticate via web browser: mkdir /Users/carmen_tur/.config/gh: permission denied
> (carmen) carmen_tur@Air-de-Carmen-2 ~ % gh auth login
> ? What account do you want to log into? GitHub.com
> ? What is your preferred protocol for Git operations? HTTPS
> ? Authenticate Git with your GitHub credentials? Yes
> ? How would you like to authenticate GitHub CLI? Paste an authentication token
> Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
> The minimum required scopes are 'repo', 'read:org', 'workflow'.
> ? Paste your authentication token: ****************************************
> - gh config set -h github.com git_protocol https
> ✓ Configured git protocol
> mkdir /Users/carmen_tur/.config/gh: permission denied
> (carmen) carmen_tur@Air-de-Carmen-2 ~ %

Did you run sudo at some point?

ls -hald /Users/carmen_tur/.config/gh /Users/carmen_tur/.config/ /Users/carmen_tur/

It looks like the GitHub CLI tries to create a file (/Users/carmen_tur/.config/gh), but can’t do so because it doesn’t have the right permissions.

You can look up the permissions/ownership for the .config directory in question by running:

$ cd /Users/carmen_tur/
$ ls -al

Make sure to redact any sensitive file/directory names from the output, we’re mostly interested in the output line starting with .config.