unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: "João Távora" <joaotavora@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	arne_bab@web.de, jporterbugs@gmail.com,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: Stability of core packages (was: Not easy at all to upgrade :core packages like Eglot)
Date: Thu, 20 Apr 2023 02:25:00 +0300	[thread overview]
Message-ID: <e08487ea-799c-ba5b-2fb4-5c5612bbb0bb@gutov.dev> (raw)
In-Reply-To: <CALDnm53vPnODxpv_=nvOHRjLX-PfhyTS0MFudR0qZ3Pa-Lw-AQ@mail.gmail.com>

Not sure about the reason emacs-devel was lost from Cc. That could be my 
fault: I removed it before sending the first version of the grandparent 
email, but then I thought I managed to abort that delivery and resend it 
properly.

Anyway, adding it back and replying with a full quote.

On 20/04/2023 01:49, João Távora wrote:
> On Wed, Apr 19, 2023 at 11:01 PM Dmitry Gutov <dmitry@gutov.dev> wrote:
> 
>> I think one of the conclusions to be made here is that even if
>> (package-install 'eglot) now installs the newest version of Eglot in
>> Emacs 29,
>>
>>     (use-package 'eglot :ensure t)
>>
>> still won't do that in Emacs 29 because (package-installed-p 'eglot)
>> returns t still. So the commit 580d8278c5f48 doesn't help with your
>> "most common upgrade method" cited below, if they rely on use-package
>> instead of calling 'package-install' directly.
> 
> Right, that's likely.
> 
>> The patch I +1'd here https://debbugs.gnu.org/62720#467 wouldn't help
>> with (use-package 'eglot :ensure t) either, IIUC.
> 
> That's also likely.  So we'd need this:
> 
> diff --git a/lisp/use-package/use-package-ensure.el
> b/lisp/use-package/use-package-ensure.el
> index e0ea982594e..95e6a9e95d5 100644
> --- a/lisp/use-package/use-package-ensure.el
> +++ b/lisp/use-package/use-package-ensure.el
> @@ -160,7 +160,9 @@ use-package-ensure-elpa
>           (when (consp package)
>             (use-package-pin-package (car package) (cdr package))
>             (setq package (car package)))
> -        (unless (package-installed-p package)
> +        (when (or (and (memq package package--safely-upgradeable-builtins)
> +                       (not (assoc 'eglot (package--alist))))
> +                  (not (package-installed-p package)))
>             (condition-case-unless-debug err
>                 (progn
>                   (when (assoc package (bound-and-true-p

All right, this part would "fix" (use-package eglot :ensure t).

>> Do we want to change the semantics of 'package-install' just so the
>> (minor) fraction of users who call this function directly will get Eglot
>> upgraded when starting over from an empty config with Emacs 29? And/or
>> change (package-installed-p 'eglot) to return nil when the appropriate
>> user option is set? I'm not sure that's wise, certainly not the latter.
> 
> We don't _have_ to change the semantics.  We can get exactly the same
> semantics if we want to.  Patch below:

What kind of semantics do we get with it?

1. (use-package eglot :ensure t) considers select builtin packages to be 
"not installed" for the purposes of ":ensure t".
2. 'M-x package-install' allows installing them. It doesn't allow 
installing any other package for which (package-installed-p 'xxx) 
returns t, but allows installing (essentially upgrading) these ones 
(either just eglot, or both eglot and use-package).
3. 'M-x package-update RET eglot RET' still doesn't work unless eglot 
has been "upgraded" at least once via other means.

Is that logical? Is even just 1+2 logical?

And what about capabilities that we lose that way? I guess one of the 
reasons to bundle ELPA packages is to make sure they can be used without 
additional installation. E.g. in some Internes-less network, or one 
that's firewalled off. Let's also imagine that (for example) clangd is 
already installed through other means, which is also within the realm of 
possibility.

And take use-package. Which some people position as the new way to write 
the Emacs configuration.

The user puts the snippet which they saw on the Internet

   (use-package eglot :ensure t)

either because they think it's a good idea, or because they intend to 
add some actual config in there, restart Emacs and... startup fails 
because the package can't be installed (no connection). Should they 
remove ":ensure t"? Perhaps. But the documentation says that that option 
checks that the package is "installed automatically if not already 
present on your system". Seems legit, right? Why would startup fail when 
Eglot is already present on the system?

Or, to put it another way, why did we decide to bundle Eglot with Emacs 
if the first thing we're going to do is to try to download it anyway?

So... I understand the problem, but I think we shouldn't change the 
functions in a way that makes them conflict with documentation or with 
each other.

> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> index 685f983e285..850f4ad3a7a 100644
> --- a/lisp/emacs-lisp/package.el
> +++ b/lisp/emacs-lisp/package.el
> @@ -652,6 +652,12 @@ package--builtins
>   name (a symbol) and DESC is a `package--bi-desc' structure.")
>   (put 'package--builtins 'risky-local-variable t)
> 
> +(defvar package--safely-upgradeable-builtins '(eglot use-package))
> +
> +(defun package--safely-upgradeable-builtin (p)
> +  (and (memq p package--safely-upgradeable-builtins) ; whitelisted
> +       (not (assoc p (package--alist))))) ; not installed already
> +
>   (defvar package-alist nil
>     "Alist of all packages available for activation.
>   Each element has the form (PKG . DESCS), where PKG is a package
> @@ -2201,14 +2207,18 @@ package-install
>        (package--archives-initialize)
>        (list (intern (completing-read
>                       "Install package: "
> +                    (append
>                        (delq nil
>                              (mapcar (lambda (elt)
>                                        (unless (package-installed-p (car elt))
>                                          (symbol-name (car elt))))
>                                      package-archive-contents))
> +                     package--safely-upgradeable-builtins)
>                       nil t))
>              nil)))
>     (package--archives-initialize)
> +  (when (package--safely-upgradeable-builtin pkg)
> +    (setq pkg (cadr (assoc pkg package-archive-contents))))
>     (add-hook 'post-command-hook #'package-menu--post-refresh)
>     (let ((name (if (package-desc-p pkg)
>                     (package-desc-name pkg)
> diff --git a/lisp/use-package/use-package-ensure.el
> b/lisp/use-package/use-package-ensure.el
> index e0ea982594e..cfa10f453d9 100644
> --- a/lisp/use-package/use-package-ensure.el
> +++ b/lisp/use-package/use-package-ensure.el
> @@ -160,7 +160,8 @@ use-package-ensure-elpa
>           (when (consp package)
>             (use-package-pin-package (car package) (cdr package))
>             (setq package (car package)))
> -        (unless (package-installed-p package)
> +        (when (or (package--safely-upgradeable-builtin package)
> +                  (not (package-installed-p package)))
>             (condition-case-unless-debug err
>                 (progn
>                   (when (assoc package (bound-and-true-p




  parent reply	other threads:[~2023-04-19 23:25 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87a5zj2vfo.fsf@gmail.com>
     [not found] ` <83wn2h5825.fsf@gnu.org>
     [not found]   ` <87wn2gkhzr.fsf@posteo.net>
     [not found]     ` <83cz485oxi.fsf@gnu.org>
     [not found]       ` <87leiwdyff.fsf@posteo.net>
     [not found]         ` <834jpk5hih.fsf@gnu.org>
     [not found]           ` <871qkom3fj.fsf@posteo.net>
     [not found]             ` <83mt3b4yfc.fsf@gnu.org>
     [not found]               ` <87edonlsxi.fsf@posteo.net>
     [not found]                 ` <83jzyf4vzb.fsf@gnu.org>
     [not found]                   ` <871qknllkj.fsf@posteo.net>
     [not found]                     ` <83fs934pjf.fsf@gnu.org>
     [not found]                       ` <87wn2fk47y.fsf@posteo.net>
     [not found]                         ` <83sfd2g2ek.fsf@gnu.org>
     [not found]                           ` <875y9yfxrr.fsf@gmail.com>
     [not found]                             ` <CALDnm50-Su4SAGDSBiLjt0yrjrVsvyW71NSMi=zt7uHgv7rdng@mail.gmail.com>
     [not found]                               ` <87y1muefks.fsf@gmail.com>
     [not found]                                 ` <CALDnm50b6hRu+4EFqQDVydOF07HdiZT4nHA=aLDjYQKtMBTk2Q@mail.gmail.com>
     [not found]                                   ` <fc2ed4a0-2368-682d-e34d-5cf94ac261fc@gutov.dev>
     [not found]                                     ` <CALDnm527Avsa-MBTD-bvRqOn52AeBLfPvffxjL-NB3tqM=43ZQ@mail.gmail.com>
     [not found]                                       ` <834jpifizy.fsf@gnu.org>
     [not found]                                         ` <CALDnm53X5Yyn_EitG+iHJVx=RO2hjNaWkrgPz0+jKVWVM=eEBQ@mail.gmail.com>
     [not found]                                           ` <83y1mue1qi.fsf@gnu.org>
     [not found]                                             ` <CALDnm51hmRMxstQdZdstA2LrbvYw=zD5=XRVy6uCU=Z+OmONRg@mail.gmail.com>
     [not found]                                               ` <83sfd2e01f.fsf@gnu.org>
     [not found]                                                 ` <1a5e5837-513b-84d8-3260-cdbf42b71267@gutov.dev>
     [not found]                                                   ` <83sfcz9rf2.fsf@gnu.org>
     [not found]                                                     ` <09a49ab9-ac72-36a9-3e68-9c633710eba7@gutov.dev>
2023-04-18 12:57                                                       ` Stability of core packages (was: Not easy at all to upgrade :core packages like Eglot) Eli Zaretskii
2023-04-18 14:02                                                         ` João Távora
2023-04-18 14:47                                                           ` Eli Zaretskii
2023-04-18 15:45                                                             ` João Távora
2023-04-18 16:19                                                               ` Eli Zaretskii
2023-04-18 17:49                                                                 ` João Távora
2023-04-18 21:19                                                                   ` Dmitry Gutov
2023-04-18 18:56                                                         ` Jim Porter
2023-04-18 19:21                                                           ` Eli Zaretskii
2023-04-18 19:36                                                             ` Jim Porter
2023-04-19 11:55                                                               ` Eli Zaretskii
2023-04-19  8:50                                                           ` João Távora
2023-04-19 12:13                                                             ` Dr. Arne Babenhauserheide
2023-04-19 17:03                                                               ` Eli Zaretskii
2023-04-19 17:21                                                                 ` João Távora
2023-04-19 18:07                                                                   ` Eli Zaretskii
2023-04-19 18:14                                                                     ` Dmitry Gutov
2023-04-19 18:32                                                                       ` Eli Zaretskii
2023-04-19 19:33                                                                         ` João Távora
2023-04-20  4:26                                                                           ` tomas
2023-04-19 19:39                                                                         ` Dmitry Gutov
2023-04-19 19:46                                                                           ` João Távora
2023-04-19 20:50                                                                             ` Dmitry Gutov
2023-04-19 20:57                                                                               ` João Távora
2023-04-19 21:58                                                                                 ` Jim Porter
2023-04-19 22:29                                                                                   ` João Távora
2023-04-19 22:42                                                                                     ` Jim Porter
2023-04-19 22:58                                                                                       ` João Távora
2023-04-19 22:06                                                                                 ` Dmitry Gutov
2023-04-19 22:21                                                                                   ` Jim Porter
2023-04-19 22:27                                                                                     ` Dmitry Gutov
2023-04-19 22:43                                                                                       ` Jim Porter
     [not found]                                                                                 ` <f32d7008-ea39-a9d7-8224-2c5b969236b7@gutov.dev>
     [not found]                                                                                   ` <CALDnm53vPnODxpv_=nvOHRjLX-PfhyTS0MFudR0qZ3Pa-Lw-AQ@mail.gmail.com>
2023-04-19 23:25                                                                                     ` Dmitry Gutov [this message]
2023-04-20  0:13                                                                                       ` João Távora
2023-04-20  1:13                                                                                         ` Dmitry Gutov
2023-04-20  1:49                                                                                           ` João Távora
2023-04-20  2:04                                                                                             ` Dmitry Gutov
2023-04-19 19:15                                                                     ` João Távora
2023-04-20  9:38                                                                       ` Eli Zaretskii
2023-04-20  9:48                                                                         ` João Távora
2023-04-20 11:47                                                                           ` Eli Zaretskii
2023-04-20 12:00                                                                             ` João Távora
2023-04-20 12:16                                                                               ` Eli Zaretskii
2023-04-20 12:24                                                                                 ` João Távora
2023-04-19 17:35                                                                 ` John Yates
2023-04-19 17:42                                                                   ` João Távora
2023-04-19 18:02                                                                   ` Eli Zaretskii
2023-04-19 18:04                                                                 ` Jim Porter
2023-04-19 18:34                                                                   ` Eli Zaretskii
2023-04-19 19:35                                                                     ` Jim Porter
2023-04-20  9:49                                                                       ` Eli Zaretskii
2023-04-19 19:40                                                                 ` Dr. Arne Babenhauserheide
2023-04-20  6:02                                                                   ` Eli Zaretskii
2023-04-29  5:21                                                                     ` Stability of core packages emacs
2023-04-29  6:26                                                                       ` Eli Zaretskii
2023-04-29 21:47                                                                         ` Mohsen BANAN
2023-04-30  6:21                                                                           ` Eli Zaretskii
2023-04-30  9:07                                                                           ` Philip Kaludercic
2023-04-30 13:12                                                                           ` Corwin Brust
2023-05-07  5:58                                                                             ` Mohsen BANAN
2023-05-05  4:36                                                                       ` David Masterson
2023-05-05  4:56                                                                       ` David Masterson
     [not found]                                                                       ` <878re3bdj6.fsf@penguin>
2023-05-05  4:59                                                                         ` David Masterson
2023-04-19 12:55                                                             ` Stability of core packages (was: Not easy at all to upgrade :core packages like Eglot) Eli Zaretskii
2023-04-19 13:18                                                               ` João Távora
2023-04-19 13:44                                                                 ` Eli Zaretskii
2023-04-19 14:13                                                                   ` João Távora
2023-04-18 22:10                                                         ` Dmitry Gutov
2023-04-19  8:34                                                           ` João Távora
2023-04-19 12:47                                                           ` Eli Zaretskii
2023-04-19 18:22                                                             ` Jim Porter
2023-04-19 18:37                                                               ` Eli Zaretskii
2023-04-19 19:32                                                                 ` Jim Porter
2023-04-19 22:51                                                                 ` Lynn Winebarger
2023-04-20 13:47                                                                   ` history of ELPA packages and dependencies (was: Stability of core packages (was: Not easy at all to upgrade :core packages like Eglot)) Lynn Winebarger
2023-04-20 13:58                                                                   ` Stability of core packages (was: Not easy at all to upgrade :core packages like Eglot) Lynn Winebarger
2023-04-19 19:25                                                             ` Dmitry Gutov
2023-04-19 19:40                                                               ` João Távora
2023-04-20  9:47                                                               ` Eli Zaretskii
2023-04-20 13:03                                                                 ` Dmitry Gutov
2023-04-20 14:03                                                                   ` Eli Zaretskii
2023-04-20 14:22                                                                     ` Dmitry Gutov
2023-04-20 14:42                                                                       ` Eli Zaretskii
2023-04-20 15:30                                                                         ` Dmitry Gutov
2023-04-20 15:49                                                                           ` Eli Zaretskii
2023-04-20 17:26                                                                             ` Stability of core packages Philip Kaludercic
2023-04-20 18:46                                                                               ` Eli Zaretskii
2023-04-20 21:25                                                                             ` Stability of core packages (was: Not easy at all to upgrade :core packages like Eglot) Dmitry Gutov
2023-04-21 14:12                                                                             ` Lynn Winebarger
2023-04-19 12:31                                                         ` What is :core? (was: Stability of core packages (was: Not easy at all to upgrade :core packages like Eglot)) Lynn Winebarger
2023-04-19 12:57                                                           ` João Távora
2023-04-19 13:03                                                           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e08487ea-799c-ba5b-2fb4-5c5612bbb0bb@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=arne_bab@web.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=jporterbugs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).