简体   繁体   中英

MacOS VSCode git only works when started code under sudo

MacOS Big Sur (11.2), VSCode v1.53.1.

I have X-code installed. All these staffs started after I installed it.
I did xcode-select --install and did sudo xcodebuild -license accept .
git was installed by brew install git .

% git --version
git version 2.30.0
% where git
/usr/local/bin/git
/usr/bin/git
% which git
/usr/local/bin/git

VSCode settings.json:

{
    "git.path": "/usr/local/bin/git"
}

when I start code like sudo code - it works, but when I start it in normal mode I see this:

在此处输入图像描述

code --disable-extensions - didn't help

Any git-related command from command pallet raised this error:

在此处输入图像描述

When I click on "clone repository..." on Wellcome screen, I see this error:

在此处输入图像描述

But, as I said, everything works fine when I start code under sudo.

I spent days trying to solve this issue, searching a lot, but still have no clue how to solve it. If anybody would help with that I'll be very appreciated.

In my case, there was a problem in .zshenv file.
Somehow there was line like this:

export TMPDIR=/tmp:$TMPDIR

And when some program tried to use the temp folder, this folder becomes unavailable, and the program has failed.
The side effects of this stuff were also failed git and a lot of other programs.
The solution was simple: just remove this line from .zshenv

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM