devcontainers / images

Repository for pre-built dev container images published under mcr.microsoft.com/devcontainers
https://containers.dev
MIT License
1.3k stars 483 forks source link

"Fatal error: git failed" in postCreateCommand on python3.11 #916

Open pamelafox opened 9 months ago

pamelafox commented 9 months ago

I am honestly not sure if this is an error with the images, Dev Containers extension, or CLI, but am starting here.

In the past week, I've gotten reports on two repositories of errors from my postCreateCommand script that worked fine before. The script calls "pre-commit install" which sets up pre-commit hooks for the current git repository. In both cases, the developer opening the dev container was indeed opening it from a git repository, so it should have worked.

Here are the reports: https://github.com/Azure-Samples/ai-rag-chat-evaluator/issues/2 https://github.com/pamelafox/simple-fastapi-container/issues/42

The error is:

"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 [18551 ms] postCreateCommand failed with exit code 1. Skipping any further user-provided commands."

The postCreateCommand is "pip install -r requirements-dev.txt && pre-commit install"

Both repositories are using "mcr.microsoft.com/devcontainers/python:3.11" although the second one is using "-bullseye" pin specifically.

Did anything change with the images in terms of their git support in the last 1-2 weeks? If not, then I'll ask the extension team if something changed on their side.

I do not believe it's an issue with pre-commit as they haven't had a recent release. Thanks!

samruddhikhandale commented 9 months ago

Hi 👋

@pamelafox Are you able to reproduce the issue today? Also, does the issue appears consistently?

I tried reproducing with the https://github.com/Azure-Samples/ai-rag-chat-evaluator repository, the codespace was created fine with successfully executed lifecycle commands.

Image

Image

pamelafox commented 9 months ago

I have never been able to replicate the issue personally, I've only gotten multiple reports from users across different repositories with similar postCreateCommand's. I believe both cases were local dev containers. I'll find out their OS.

langestefan commented 9 months ago

Hello, I have also been struggling with this issue for the past few months and have not been able to solve it.

The following project has this issue: https://github.com/langestefan/python-package-template

I am currently testing this on windows 11, but the issue was also present on ubuntu and mint at some point.

- Edit: -

It seems to be caused by files going corrupt when rebuilding the container. I had a bunch of permission denied errors from git status. Running ll revealed files with permissions looking like this:

drwxr-xr-x 
??????????  
drwxr-xr-x
?????????? 

Rebuilding the container, or rebuilding without cache didn't solve this. So I deleted the project and pulled it from git, now git status was working as expected again. I was then also able to use git normally. Let's see for how long this keeps working.

- Edit 2: -

Made a new repository based on my template, issue is back. It seems related to this: https://github.com/microsoft/vscode-remote-release/issues/7628