jabranham / system-packages

Moved to gitlab
https://gitlab.com/jabranham/system-packages
GNU General Public License v3.0
39 stars 12 forks source link

Permission denied error on Debian buster #27

Closed ghost closed 6 years ago

ghost commented 6 years ago

I recently upgraded my system from Debian Stretch (stable) to Debian Buster (testing). I have not been able to get system-packages-update to work properly since this upgrade. The function does not prompt me for a sudo password as it once did, but instead fails with a permissions error:

Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

My configuration for system-packages is pretty minimal:

(use-package system-packages
  :ensure t
  :bind
  ("C-c s s" . system-packages-search)
  ("C-c s u" . system-packages-update)
  (setq system-packages-package-manager 'apt))
ghost commented 6 years ago

I don't know if system-packages uses auth-sources, but in case it does, I don't have anything in mine for localhost.

jabranham commented 6 years ago

I don't think that use-package statement will work. Did you omit a :config?

Can you check the value of system-packages-use-sudo and system-pacakges-package-manager?

jabranham commented 6 years ago

Also, I'm assuming that sudo apt-get update and sudo apt-get upgrade work from the command line?

ghost commented 6 years ago

:man_facepalming: Yes to both. I fixed my config, and it's working again. Thank you, and sorry for the noise.

ghost commented 6 years ago

Ah, I think I figured out what happened. After 1) changing the config to the following:

(use-package system-packages
  :ensure t
  :bind
  ("C-c s u" . system-packages-update)
  ("C-c s s" . system-packages-search)
  :config
  (setq system-packages-package-manager 'apt))

and 2) restarting Emacs, it was still not prompting for a sudo password. I then remembered that I recently installed nix on my machine. system-packages was finding nix first, and setting system-packages-package-manager to nix-env, which does not use sudo. Then, I'm setting it in my :config section to apt, which does use sudo.

Here's my new config, which is working as expected:

(use-package system-packages
  :ensure t
  :bind
  ("C-c s u" . system-packages-update)
  ("C-c s s" . system-packages-search)
  :config
  (setq system-packages-package-manager 'apt)
  (setq system-packages-use-sudo t))

I also tried setting system-packages-package-manager to apt in the :init section. This method worked, but then Emacs wasn't picking up the variable's documentation string from system-packages.el.

Thanks, and sorry again for the noise.

jabranham commented 6 years ago

Yeah, if you change system-packages-package-manager you also (might) have to change system-packages-use-sudo. This is documented in the README, but should probably be more visible.

Glad you got it working!