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

Permission denied to read file #1519

Closed
barenko opened this issue Jan 15, 2021 · 11 comments
Closed

Permission denied to read file #1519

barenko opened this issue Jan 15, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@barenko
Copy link

barenko commented Jan 15, 2021

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)

@barenko barenko added the bug Something isn't working label Jan 15, 2021
@Enselic
Copy link
Collaborator

Enselic commented Jan 15, 2021

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

@sharkdp
Copy link
Owner

sharkdp commented Jan 15, 2021

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.)

@barenko
Copy link
Author

barenko commented Jan 15, 2021

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

Enselic added a commit to Enselic/bat that referenced this issue Jan 22, 2021
As discussed in sharkdp#1519, the batcat snap package is too problematic for
official endorsement, so withdraw recommendation from README.me (and
remove section from CHANGELOG.md since a release with it has not been
made yet).
sharkdp pushed a commit that referenced this issue Feb 15, 2021
As discussed in #1519, the batcat snap package is too problematic for
official endorsement, so withdraw recommendation from README.me (and
remove section from CHANGELOG.md since a release with it has not been
made yet).
@sharkdp sharkdp closed this as completed Feb 15, 2021
@pjgoodall
Copy link

I have this problem too

% batcat --version      
bat 0.18.2

@Enselic
Copy link
Collaborator

Enselic commented Jul 26, 2021

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

@purveshpatel511
Copy link
Contributor

@pjgoodall , Or reinstall snap using following command,

sudo snap install batcat --devmode

@pjgoodall
Copy link

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.

@purveshpatel511
Copy link
Contributor

@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.

@Enselic
Copy link
Collaborator

Enselic commented Jul 26, 2021

@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.

@sharkdp
Copy link
Owner

sharkdp commented Jul 26, 2021

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

@purveshpatel511
Copy link
Contributor

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants