profclems / glab

The GitLab CLI tool. Archived: now officially adopted by GitLab as the official CLI tool and maintained at https://gitlab.com/gitlab-org/cli. See https://github.com/profclems/glab/issues/983

Home Page:https://glab.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snap package needs system-files plug for issue list command to work

dplanella opened this issue · comments

Description

On Ubuntu 20.04, with glab 1.14.0-16-g222c0c5, the glab issue list command fails due to missing permissions.

It seems that glab is trying to access /etc/gitconfig. However, it cannot in a non --classic install (as recommended in the glab documentation), as the snap only has access to files in the user's home directory.

Expected Behavior vs Actual Behavior

  • Expected: glab issue list works after successful authentication
  • Actual: glab issue list fails with the following error:

warning: unable to access '/etc/gitconfig': Permission denied

Possible Fix

  1. Provide a system-files plug for the snap
  2. Recommend to install with sudo snap install glab --edge --classic => does not work either
  3. Remove the snap and install the .deb package instead

Steps to Reproduce

$ glab issue list
warning: unable to access '/etc/gitconfig': Permission denied
warning: unable to access '/etc/gitconfig': Permission denied
fatal: unknown error occurred while reading the configuration files
git: exit status 128

$ sudo snap connect glab:system-files
error: snap "glab" has no plug named "system-files"

Logs

See above

Your Environment

  • Version used (Run glab --version): 1.14.0-16-g222c0c5
  • Operating System and version: Ubuntu 20.04

Thanks for reporting this issue @dplanella

glab runs git commands in a subprocess to get your git config, logs, etc, It does not directly access the git config file.
I have not dived into snap internals so I can't tell why it's having this issue.

I think the snap currently works well for users with global git config file located at the homedir (~/.gitconfig).

Do you mind opening a PR to add a system-files plug that allows read-write to /etc/gitconfig?

Thanks @profclems for the quick reply!

I think the snap currently works well for users with global git config file located at the homedir (~/.gitconfig).

Unfortunately, I don't think it's the case. I'm one of those users with a ~/.gitconfig file, but it seems (git?) still wanted to access /etc/gitconfig

Do you mind opening a PR to add a system-files plug that allows read-write to /etc/gitconfig?

Sure. It's been a few years since I touched any snap code, so I'm not really an expert, but happy to give it a go.

@profclems here you go: #599

Thanks, that was quick!

I will have a look at it asap... I just took a break from the computer