Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inside .git folders Agnoster produces "fatal: this operation must be run in a work tree" #162

Open
rzarajczyk opened this issue Dec 10, 2021 · 4 comments

Comments

@rzarajczyk
Copy link

Hi,
When I'm inside .git directory (this special hidden dir in any git repo which store git-related data) the Agnoster produces

fatal: this operation must be run in a work tree

every time the command line is show. It is because Agnoster's git integration try to execute some git commands, like git status, in this repo - but it ends with this message produced to stderr.

@guntern
Copy link

guntern commented Oct 8, 2024

I just ran into the same issue. Surprisingly I never had seen it before. Did you find a solution? Is this really related to the agnoster-theme or is something else causing this, maybe?

@rzarajczyk
Copy link
Author

rzarajczyk commented Oct 8, 2024

Oh wow, this issue is almost 3 years old :-) Since then I've stopped using Agnoster, and the details have vanished from my memory... however, as far as I remember, I wasn't able to fix it using the original Agnoster theme, but I made a fork of the code and fixed it just for me.

The fork is here: https://github.com/rzarajczyk/agnoster-zsh-theme
The link to the changes: master...rzarajczyk:agnoster-zsh-theme:master

It should be either the line 96 of the original file

-    test -n "$(git status --porcelain --ignore-submodules)"
+    test -n "$(git status --porcelain --ignore-submodules 2> /dev/null)"

Or 155

-  vcs_info
+  vcs_info 2> /dev/null

Or both, I don't remember :-)

@guntern
Copy link

guntern commented Oct 8, 2024

Thanks. Maybe it is time to replace agnoster then as well.

@guntern
Copy link

guntern commented Oct 15, 2024

Just for documentation purposes: I dug around and it appears that the issue is not tied to agnoster, but more to zsh itself: spaceship-prompt/spaceship-prompt#821, which in the end leads to a similar solution as you proposed: zsh-users/zsh@bacad96
Testing in bash worked without the error, which indicates that it is related to zsh. I am currently using zsh 5.8. But also in a test-container with zsh 5.9 I have the same issue. Let's see where this leads me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants