sharkdp / bat

A cat(1) clone with wings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Permission denied to read file

barenko opened this issue · comments

What version of bat are you using?
bat 0.17.1

Describe the bug you encountered:
I Have a file with read permission:
.rw-r--r-- 7,0k myuser 14 Jan 23:16 .zshrc

I tried to read normally (with the file owner)
batcat .zshrc
[bat error]: '.zshrc': Permission denied (os error 13)

I retried using sudo:
sudo batcat /home/myuser/.zshrc
[bat error]: '/home/myuser/.zshrc': Permission denied (os error 13)

...

What did you expect to happen instead?
show the file contents
...

How did you install bat?
using the snap package


Environment

system

$ uname -srm
Linux 5.4.0-26-generic x86_64

$ lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description: Linux Mint 20
Release: 20
Codename: ulyana

bat

$ batcat --version
bat 0.17.1

$ env
PAGER=less

bat_config

bat_wrapper

No wrapper script for 'bat'.

No wrapper script for 'batcat'.

bat_wrapper_function

No wrapper function for 'bat'.

No wrapper function for 'cat'.

No wrapper function for 'batcat'.

tool

$ less --version
less 551 (GNU regular expressions)

Thanks for taking the time to report a bug!

I have a handful of questions:

  1. Do you have the same problem with other files with the same permissions?
  2. Do you have the same problem when you use cat instead of batcat?
  3. Are there any symbolic links involved? Please provide the full output of ls -l /home/myuser/.zshrc (you seem to have redacted some parts in the output you include, since the group info is missing)
  4. Also provide the output of whoami please

How did you install bat?
using the snap package

I'm pretty sure this is the problem. Others had similar issues when installing from snap (#1424). FYI @purveshpatel511

To be honest, I am considering to remove the snap install instructions from the README. I don't want users to go through this experience. I remember that ripgrep did something similar because they encountered too many bugreports concerning wrong permissions.

Unless that problem can be fixed in the snap package itself (classic confinement), I would discourage from installing via snap.

@barenko Could you try to install bat from the packages in this repository and see if that fixes your problem? https://github.com/sharkdp/bat/releases/tag/v0.17.1

Edit: Quoting from the ripgrep README (see BurntSushi/ripgrep@6ffb4b7):

(N.B. Various snaps for ripgrep on Ubuntu are also available, but none of them seem to work right and generate a number of very strange bug reports that I don't know how to fix and don't have the time to fix. Therefore, it is no longer a recommended installation option.)

Hi @sharkdp , the snap really is the problem. I reinstalled the bat using cargo and works well!

I have this problem too

% batcat --version      
bat 0.18.2

@pjgoodall Try one of the recommended installation methods instead of installing from snap: https://github.com/sharkdp/bat#installation

@pjgoodall , Or reinstall snap using following command,

sudo snap install batcat --devmode

There is no apt package for batcat, for Ubuntu 20.04 which is why I used snap - which is on the list I think.
The cargo install worked, though heavyweight. I should have tried the deb package.

Snap is for a number of serious sub-systems on Ubuntu, such as LXD. It is a bug that the snap doesn’t work.

@Enselic, I am a maintainer of snap package and I tried to resolve this permission issue but not getting positive response from review-team of snapstore. So, i pulled down release of bat. Maybe you guys should also remove the snap install instruction from readme file so no new user try to search on store and come back with an issue.

@purveshpatel511 Thank you for your efforts to try to build a working snap package. Sorry to hear it is difficult to make it work well.

I think we should keep the section in the README that advices against using the snap package, because I’m sure it will stay around in one way or another even if you pulled it from the store.

Thank you @purveshpatel511. I think that's the best option for now. It looks like the snap package is still available though? https://snapcraft.io/batcat

@Enselic and @sharkdp, Thanks for support.

It looks like the snap package is still available though?

I already pulled down all the release of the package but user with the URL can still access the web-page but cannot able to install the package. Also i listed snap to private so no new user can find it in a store. Here, you can check that out, https://snapcraft.io/search?q=batcat
Currently, there are 550+ active user of batcat so listing page of snap is still accessible via direct link.

https://github.com/sharkdp/bat#installation

I checked out above installation information and found that there has approx 19 Linux distribution that not got the latest stable release(v0.18.2) of the package including Ubuntu, Fedora, Kali, Debian, openSUSE and Alpine. And we can resolve this with snap package.

What am I proposing?
Here I attach snap package.
batcat_0.18.2_amd64.zip

You can list this snap package in your release page and direct snap lovers to download and install snap from your release page.

User can install this package with following command,
sudo snap install <package_name>.snap --dangerous --classic
in this case,
sudo snap install batcat_0.18.2_amd64.snap --dangerous --classic

Bit information about the flags,
--dangerous : used while user is try to manually install local package that is not listed on snapstore.
--classic : Confinement level, allow snap to access any file on system. (main issue of previous package)

By using this snap package, we can also resolve the previous issues #1424.

Also i can build snap for different architecture including arm64, armhf, i386 and amd64.

Give it a try. If you guys find this useful then we can work ahead.
And you can uninstall snap package using command,
sudo snap remove <package_name>.snap --purge