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

Right prompt prints "Permission Denied" errors to fish stderr. #9975

Closed
NiklasBeierl opened this issue Aug 23, 2023 · 5 comments
Closed

Right prompt prints "Permission Denied" errors to fish stderr. #9975

NiklasBeierl opened this issue Aug 23, 2023 · 5 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@NiklasBeierl
Copy link

NiklasBeierl commented Aug 23, 2023

System info

> echo $TERM
tmux-256color
> fish --version
fish, version 3.6.1
> uname -a
Linux <HOSTNAME> 6.4.7-arch1-2 #1 SMP PREEMPT_DYNAMIC Mon, 31 Jul 2023 11:41:04 +0000 x86_64 GNU/Linux

The default fish_right_prompt uses git rev-parse --git-dir 2>/dev/null to determine if it is inside a git repository.

That causes git (or at least version 2.41.0) to check all directories that are .gitignored for a file called .gitkeep.
If this .gitignored folder is not readable for the current user, fish prints: path/to/ignored_dir/.gitkeep: Permission denied to its own stderr. Since fish_right_prompt gets run anytime I run any command, I get this error anytime I do anything in an affected git repository. This does not occur when running the git rev-parse command in bash.

A ~ echo $0
-bash
A ~ cd code/swag/swager/
A ~/code/swag/swager (main) git rev-parse --git-dir
.git
A ~/code/swag/swager (main) fish
docker/volumes/postgres/.gitkeep: Permission denied
A ~/c/s/swager git rev-parse --git-dir                                    main ⬆ ✖ ✱ ◼
.git
docker/volumes/postgres/.gitkeep: Permission denied
A ~/c/s/swager cd ..                                                      main ⬆ ✖ ✱ ◼
A ~/c/swag cd
A ~ cd code/swag/swager/
docker/volumes/postgres/.gitkeep: Permission denied
A ~/c/s/swager cd docker/                                                 main ⬆ ✖ ✱ ◼
docker/volumes/postgres/.gitkeep: Permission denied
A ~/c/s/s/docker cd volumes/                                              main ⬆ ✖ ✱ ◼
docker/volumes/postgres/.gitkeep: Permission denied        

And it is definitely fish printing this message! If i redirect fish's stderr to /dev/null, I do not get the output:

A ~ fish 2>/dev/null
A ~ cd code/swag/swager/
A ~/c/s/swager cd docker/    

I am also confident that fish_right_prompt is causing the access to the .gitkeep files, because disabling it also makes the messages go away:

A ~ fish
A ~ cd code/swag/swager/
docker/volumes/postgres/.gitkeep: Permission denied
A ~/c/s/swager cd .                                                       main ⬆ ✖ ✱ ◼
docker/volumes/postgres/.gitkeep: Permission denied
A ~/c/s/swager functions -e fish_right_prompt                             main ⬆ ✖ ✱ ◼
A ~/c/s/swager cd docker
A ~/c/s/s/docker cd ../
A ~/c/s/swager

You might be wondering why I have a gitignored directory that my user may not read from:
It is used as a volume for a docker container running postgres, the container runs with a different uid and sets the permissions of the directory.

@NiklasBeierl NiklasBeierl changed the title Git prompt prints "Permission Denied" errors to fish stderr. Right prompt prints "Permission Denied" errors to fish stderr. Aug 23, 2023
@zanchey
Copy link
Member

zanchey commented Aug 23, 2023

The default fish_right_prompt uses git rev-parse --git-dir 2>/dev/null to determine if it is inside a git repository.

fish does not ship with a default fish_right_prompt. What theme are you using?

@NiklasBeierl
Copy link
Author

NiklasBeierl commented Aug 23, 2023

Oh, I see. I admit one of the first things I did was select a color theme via fish_config.
I can't seem to figure out which one I selected. :/

@NiklasBeierl
Copy link
Author

Maybe this helps:
My ~/.config/fish/functions/fish_right_prompt.fish is a subset of share/tools/web_config/sample_prompts/scales.fish

My version of the file is missing the first 23 lines.

@faho
Copy link
Member

faho commented Aug 23, 2023

Okay, run this:

function fish_right_prompt; end

That should remove the errors from the prompt.

Now, run this:

command git status --porcelain

That should give you "permission denied" errors - it's the only git call in scales that doesn't have its stderr silenced, and I don't see anything else that would print that error.

The reason for them is that you have git directory above your current directory, that git finds, but it's inaccessible to git. That seems like a weird setup.

Nevertheless, we can silence that git call as well.

This does not occur when running the git rev-parse command in bash.

Note: It doesn't happen when running git rev-parse in bash because it doesn't happen for git rev-parse. The shell has very little to do with that.

@faho faho closed this as completed in 5b1ff94 Aug 23, 2023
@faho faho added this to the fish 3.7.0 milestone Aug 23, 2023
@faho faho added bug Something that's not working as intended and removed question labels Aug 23, 2023
@NiklasBeierl
Copy link
Author

Thanks for the fix! ❤️ Sorry for misattributing the print, guess I need to up my strace game.

faho added a commit that referenced this issue Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

3 participants