ttscoff/mdless

Snap install trying to access '/etc/gitconfig'

ca-wvestjens opened this issue · 7 comments

My install through Snap on Ubuntu is trying to access /etc/gitconfig, but I guess it's not allowed because of the snap sandbox.

Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy

snap    2.60.3
snapd   2.60.3
series  16
ubuntu  22.04
kernel  6.2.0-32-generic
$ mdless README.md
warning: unable to access '/etc/gitconfig': Permission denied
warning: unable to access '/etc/gitconfig': Permission denied

Can I offer anything in regards to further debug data or information to help figure out what's happening? I've already set the $GIT_PAGER and $PAGER variables in my environment/shell, however I think Snap doesn't use these.

Snap is an app store for Linux, see: https://snapcraft.io/
Snap has specific security policies and sandboxing in place, I'm guessing this is why it doesn't work: https://snapcraft.io/docs/security-sandboxing

There is an 'app' for mdless there: https://snapcraft.io/mdless

I should note by the way, one of my colleagues recommended this program, he also has it installed through snap and he doesn't have this error.

In my regular shell (ZSH), it exits with code 0 and returns no output.
In a Snap shell (snap run --shell 'mdless.mdless'), I see the mentioned error:

wvestjens@wvestjens-xps:/home/wvestjens$ git config --get-all core.pager
warning: unable to access '/etc/gitconfig': Permission denied

I guess we found the cause, now for a fix...
Further context: /etc/gitconfig is the default config file used by Git if none other are configured.
What's strange though, in this snap shell, looking at environment variables:

wvestjens@wvestjens-xps:/home/wvestjens$ env | grep PAGER
PAGER=less
GIT_PAGER=less

Furthermore, I tried some variations of the -p flag to override the pager and hopefully prevent the message, but it seems like it ignores the -p flag entirely.

I can try the Gem and it'll probably work because it's not sandboxed, but I'm not sure if you want the snap version fixed, since it'll give you more reach for your (cool and beautiful!) tool.

Let me know if you can do anything with this new info.

I've stopped using the git pager for mdless because it's often something like Delta or a pretty-print utility that messes with mdless formatting. Closing this for now.