Git issue when try to build dev container

When I try to run the dev container for core I get the following error:

Requirement already satisfied: distlib<1,>=0.3.6 in /usr/local/lib/python3.9/sit
e-packages (from virtualenv>=20.0.8->pre-commit) (0.3.6)
Requirement already satisfied: platformdirs<3,>=2.4 in /usr/local/lib/python3.9/
site-packages (from virtualenv>=20.0.8->pre-commit) (2.5.4)
Requirement already satisfied: filelock<4,>=3.4.1 in /usr/local/lib/python3.9/si
te-packages (from virtualenv>=20.0.8->pre-commit) (3.8.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.9/site-packa
ges (from nodeenv>=0.11.1->pre-commit) (58.1.0)
Installing collected packages: colorlog
Successfully installed colorlog-6.7.0
WARNING: You are using pip version 22.0.4; however, version 22.3.1 is available.
You should consider upgrading via the '/usr/local/bin/python3 -m pip install --u
pgrade pip' command.
An error has occurred: FatalError: git failed. Is it installed, and are you in a
 Git repository directory?
Check the log at /home/vscode/.cache/pre-commit/pre-commit.log
[18684 ms] postCreateCommand failed with exit code 1. Skipping any further user-provided commands.
Done. Press any key to close the terminal.

Here the log from the /home/vscode/.cache/pre-commit/pre-commit.log file

### version information

pre-commit version: 2.20.0

git --version: git version 2.38.1


    3.9.15 (main, Oct 26 2022, 03:47:43)

    [GCC 10.2.1 20210110]

sys.executable: /usr/local/bin/python posix

sys.platform: linux

### error information

An error has occurred: FatalError: git failed. Is it installed, and are you in a Git repository directory?

Traceback (most recent call last):

  File "/usr/local/lib/python3.9/site-packages/pre_commit/", line 58, in get_root

    cmd_output('git', 'rev-parse', '--show-cdup')[1].strip(),

  File "/usr/local/lib/python3.9/site-packages/pre_commit/", line 152, in cmd_output

    returncode, stdout_b, stderr_b = cmd_output_b(*cmd, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/pre_commit/", line 146, in cmd_output_b

    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)

pre_commit.util.CalledProcessError: command: ('/usr/local/bin/git', 'rev-parse', '--show-cdup')

return code: 128

expected return code: 0

stdout: (none)


    fatal: detected dubious ownership in repository at '/workspaces/core'

    To add an exception for this directory, call:


      git config --global --add /workspaces/core


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/usr/local/lib/python3.9/site-packages/pre_commit/", line 73, in error_handler


  File "/usr/local/lib/python3.9/site-packages/pre_commit/", line 343, in main


  File "/usr/local/lib/python3.9/site-packages/pre_commit/", line 161, in _adjust_args_and_chdir

    toplevel = git.get_root()

  File "/usr/local/lib/python3.9/site-packages/pre_commit/", line 64, in get_root

    raise FatalError(

pre_commit.errors.FatalError: git failed. Is it installed, and are you in a Git repository directory?

Any suggestions how I can solve this? Git is installed within my system

Have you tried running this command in the repository and seeing what it tells you? It’s returning error code 128 but it will probably give you more descriptive output on the command line

I had the same issue.

It would seem that when building the container /workspace/core ends up being owned by root, while the git command is being run by the user vscode. Git doesn’t like running commands on repositories owned by another user.

I added the command suggested by git in the error message to the /script/setup file at around line 18:

git config --global --add /workspaces/core

I then rebuilt the container and it seemed to complete.

1 Like

I have the same issue which has appeared in a recentish update.

For me, this:


An unexpected error has occurred: PermissionError: [Errno 13] Permission denied:


Unfortunately I have the same issue with the git config command :confused:

I’ve had the same problem and running git config --global --add /workspaces/core did not work properly. I added it to the the devcontainer.json postCreateCommand and this seems to work:

  "postCreateCommand": "git config --global --add ${containerWorkspaceFolder} && script/setup",

I thought there was something wrong with my setup, but since you have the same problem, maybe I should open a PR, if it works for you too :slight_smile:


Thanks for the hint, but unfortunatly that also causes the same permission error for the pre-commit hook :frowning_face:

I hit the same issues. Ended up deleting the local repo folder entirely and still had the issues. Finally got it working after running the following command:

python3 -m pip install -e . --constraint homeassistant/package_constraints.txt

This was something removed from the bootstrap script run by the devcontainer.json a few months ago

See this github issue:

1 Like

This worked great for me too! Anyone knows why this is not part of the dev container already? Is there something I am doing wrong?

Thanks flabbamann! exactly the same on my side and your suggestion did the trick, while directly editting setup script didn’t do the magic… cool!