## TL;DR

For "EACCES: permission denied ... autocompletion.json": remove the root-owned directory: rm -rf ~/Library/Preferences/netlify. (Alternative: sudo chown -R $(whoami) ~/Library/Preferences/netlify.) 3. TL;DR: if installing netlify-cli fails with EACCES on autocompletion.json, you almost certainly ran the CLI with sudo once, and that created root-owned files under ~/Library/Preferences/netlify. Every later non-sudo run then fails.

TL;DR: if installing netlify-cli fails with EACCES on autocompletion.json, you almost certainly ran the CLI with sudo once, and that created root-owned files under ~/Library/Preferences/netlify. Every later non-sudo run then fails. The fix: delete that directory (or chown it back to your user), reinstall and run everything without sudo, and never run ntl with sudo again.

The error, verbatim:

```text
EACCES: permission denied ... autocompletion.json
```

## Steps

1. Confirm the ownership problem: `ls -la ~/Library/Preferences/netlify`. Expected: files owned by root while you are running as your normal user.

2. Remove the root-owned directory: `rm -rf ~/Library/Preferences/netlify`. (Alternative: `sudo chown -R $(whoami) ~/Library/Preferences/netlify`.)

3. Reinstall and run the CLI without sudo: `npm install -g netlify-cli`, then `ntl login` as your normal user. Expected: install completes, no EACCES.

4. Success check: `ntl status` works without sudo and you can log into the dashboard.

## When to use this

- netlify-cli install or first run fails with EACCES permission denied on autocompletion.json.
- The CLI works under sudo but fails as your normal user.

## When NOT to use this

- npm registry or network errors during install; those are not permission problems.
- A different file path in the EACCES error; check that path's ownership instead.

## Compatibility

- netlify-cli on macOS, reproduced by a maintainer in January 2022. Same pattern applies wherever the CLI writes its preferences dir.

## Variant phrasings

- netlify cli EACCES autocompletion.json permission denied
- ntl only works with sudo after install
- netlify-cli install fails permission denied mac

## Root cause

The first sudo run created files under the user's preferences directory owned by root. Every later non-sudo run hit EACCES writing to those files. Running the install with sudo seemed to help but just entrenched the problem, since the CLI then only worked under sudo.

## Edge cases

- If you already installed the CLI itself with sudo, reinstall it as your user too; a root-owned global install can cause follow-on EACCES errors on updates.
- nvm users hit this too; the fix is the same regardless of how node was installed.
