Joanne Wei
Joanne Wei

Reputation: 201

Unable to read current working directory: Operation not permitted

I am a beginner. I try to use git to create the user's name. but when I typed

git config --global user.name "XXX"

the message shows

Unable to read current working directory: Operation not permitted.

I don't know what happened. How can I fix this problem?

Upvotes: 18

Views: 53064

Answers (3)

doox911
doox911

Reputation: 499

I got this error in a pretty silly situation. I had a directory open in the terminal, but in Finder, I moved it to another location.

So, I was trying to execute this command in a directory that no longer existed.

I hope this helps someone :)

Upvotes: 2

kenecaswell
kenecaswell

Reputation: 7598

I had a similar problem after updating to MacOS Catalina 10.15 and updating Xcode Command-line Tools (xcode-select --install).

I received the above error when simply trying to do git status. Then noticed I couldn't even do ls. Apparently it's necessary grant Terminal, or iTerm in my case, "Full Disk Access".

  1. Go to System Preferences -> Security & Privacy -> Privacy tab
  2. Select "Full Disk Access" from the left-side menu
  3. Add Terminal and/or iTerm to the app list

See this article for more details: https://osxdaily.com/2018/10/09/fix-operation-not-permitted-terminal-error-macos/

UPDATE - 1/2023: I recently updated to MacOS Ventura 13.1 and ran into the same issue. Running xcode-select --install did the trick for me. Another helpful article.

Upvotes: 78

ceth
ceth

Reputation: 45295

Check your home directory and .gitconfig file permissions using ls -l command. If all is ok try to use sudo chattr -i .gitconfig to check immutable attribute on this file.

You can find details about this command and file attributes here.

Upvotes: 1

Related Questions