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

/usr/games/pacman vs /usr/bin/apt #1060

Open
barak opened this issue Aug 4, 2023 · 5 comments
Open

/usr/games/pacman vs /usr/bin/apt #1060

barak opened this issue Aug 4, 2023 · 5 comments
Labels
moreinfo notabug Not a bug in use-package

Comments

@barak
Copy link

barak commented Aug 4, 2023

I run Debian and am a fun-loving bloke so /usr/games is on my path and pacman (the game) is installed. When use-package loads and searches for an appropriate value for system-packages-package-manager it finds /usr/games/pacman so the variable gets set to "pacman" instead of "apt".

Woka woka woka.

👻 👻 👻

@skangas skangas added moreinfo notabug Not a bug in use-package labels Aug 5, 2023
@skangas
Copy link
Collaborator

skangas commented Aug 5, 2023

I believe this was a bug in system-packages on GNU ELPA. I have pushed a new version 1.0.12 with a fix, which should be available to install from GNU ELPA within 24-48 hours.

Could you please test it and report back whether it works or not?

@barak
Copy link
Author

barak commented Aug 6, 2023

This was actually using the Debian package elpa-use-package version 2.4.4-1.

@skangas
Copy link
Collaborator

skangas commented Aug 7, 2023

Does adding this to the very beginning of your Init file, and then restarting Emacs, solve the problem?

(setq system-packages-package-manager
  (let ((managers system-packages-supported-package-managers)
        manager)
    (while managers
      (progn
        (setq manager (pop managers))
        (let ((found (executable-find (symbol-name (car manager)))))
          (if (and found
                   ;; The package manager named "pacman" conflicts
                   ;; with the game binary on non-Arch systems.
                   (not (string-match (rx "games/pacman" eos) found)))
              (setq managers nil)
            (setq manager nil)))))
    (car manager)))

@barak
Copy link
Author

barak commented Aug 8, 2023

That works, on my machine, as of today. But seems to me it's not robust because someone on an Arch system might have both /usr/bin/pacman (the package manager) and /usr/games/pacman (the arcade game clone) and have /usr/games before /usr/sbin on their path.

I'd suggest putting "apt" before "pacman" in the search list, just based on popularity. That's a stop-gap though.

Unfortunately I don't think there's any truly correct solution based on scanning for an executable. Sometimes people have multiple package managers installed: their native one, and also some "alien" ones for various purposes. There's a Debian package rpm that provides /usr/bin/rpm, and there's a Debian package pacman-package-manager that provides /usr/bin/pacman. The only solution I can see is to determine which distribution you're on, and case off that. I think /etc/os-release is standard for this purpose.

c0001 pushed a commit to c0001/elpa that referenced this issue Aug 13, 2023
* system-packages.el (system-packages-package-manager): Don't try to
use /usr/games/pacman.
Ref: jwiegley/use-package#1060
@skangas
Copy link
Collaborator

skangas commented Sep 8, 2023

I'd suggest putting "apt" before "pacman" in the search list, just based on popularity. That's a stop-gap though.

I've now done this and released version 1.0.13, which should be on GNU ELPA shortly. Thanks.

liudonghua123 pushed a commit to liudonghua123/elpa that referenced this issue Sep 14, 2023
* system-packages.el (system-packages-supported-package-managers):
Move pacman to the end of the list to avoid conflicts.
Ref: jwiegley/use-package#1060
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moreinfo notabug Not a bug in use-package
Projects
None yet
Development

No branches or pull requests

2 participants