Subject: bug#62541: 28.2; Dependencies of packages available both built-in and in external repos

From: Gustavo Barros <[email-masked]>
Date: Thu, 30 Mar 2023 08:40:08 -0300

Hi All,

since some time I've been noticing what I think is an odd behavior of
`package.el' when it comes to packages that have been incorporated to
the core, but are also distributed by external package repositories.

For example, if I install `magit' or `rg', which are available only in
external repositories, but which have a dependency to `transient'
which is available both built-in and externally, `transient' is
installed from an external repository, even though it is of the same
version as the one currently built-in.

Details: `rg` requires `(transient "0.3.0")`, `magit` requires
`(transient "0.3.6")`. The currently released version of `transient`
is "0.3.7", which is the same version which is available built-in
(Emacs 28.2).

Updating, e.g. `rg`, brings `transient` from the external repository,
even though it is the same version as the built-in one and not a
version required by the package. (I think the same happens to `magit`
as I recall, the `rg` was just the most recent upgrade I got, and the
problem occured).

I may be missing something, but I don't see a way to configure this in
`package-archive-priorities` (as far as I get the docstring, what I'm
asking is different from setting negative priorities). What I have
here is the following:

    (setq package-archives
          '(("melpa"        . "https://melpa.org/packages/")
            ("gnu-elpa-dev" . "https://elpa.gnu.org/devel/")
            ("melpa-stable" . "https://stable.melpa.org/packages/")
            ("nongnu-elpa"  . "https://elpa.nongnu.org/nongnu/")
            ("gnu-elpa"     . "https://elpa.gnu.org/packages/")))
    (setq package-archive-priorities '(("gnu-elpa"     . 2)
                                       ("nongnu-elpa"  . 2)
                                       ("melpa-stable" . 2)
                                       ("gnu-elpa-dev" . 1)
                                       ("melpa"        . 1)))

Is there a way to tell `package.el' to "prefer built-in"? Is there a
way to tell `package.el' to install from an external source only if
the dependency is strictly required?

Best regards,
Gustavo.

In GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.33,
cairo version 1.16.0)
 of 2023-02-07 built on gusbrs-desktop
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Linux Mint 21.1