unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* package-autoremove ?
@ 2020-09-03  4:35 David Masterson
  2020-09-03  6:38 ` Pankaj Jangid
  0 siblings, 1 reply; 13+ messages in thread
From: David Masterson @ 2020-09-03  4:35 UTC (permalink / raw)
  To: help-gnu-emacs

The package-autoremove is giving a list of packages to be removed, but
many of the packages seem to be dependents of other packages, so I don't
want to remove them.  How does package-autoremove decide on which
packages can be removed?  Can I force it to keep some of the packages?
-- 
David Masterson



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2020-09-03  4:35 David Masterson
@ 2020-09-03  6:38 ` Pankaj Jangid
  0 siblings, 0 replies; 13+ messages in thread
From: Pankaj Jangid @ 2020-09-03  6:38 UTC (permalink / raw)
  To: David Masterson; +Cc: help-gnu-emacs

David Masterson <dsmasterson92630@outlook.com> writes:

> The package-autoremove is giving a list of packages to be removed, but
> many of the packages seem to be dependents of other packages, so I
> don't want to remove them.  How does package-autoremove decide on
> which packages can be removed?  Can I force it to keep some of the
> packages?

I have faced a similar issue when I was re-writing my init.el to
modularize using use-package. It split the big file into tiny little
files.

In my case, the problem was that the packages where installed as a
dependency and actual call (use-package package-name :ensure t) for
those packages were not encountered by the interpreter.

I debugged it using a very inefficient method. Commented out the
(require ...)  statements from the init.el and uncommented one-by-one to
find the problem.







^ permalink raw reply	[flat|nested] 13+ messages in thread

* package-autoremove ?
@ 2023-08-22  4:00 David Masterson
  2023-08-22 12:17 ` Rudolf Schlatte
  0 siblings, 1 reply; 13+ messages in thread
From: David Masterson @ 2023-08-22  4:00 UTC (permalink / raw)
  To: help-gnu-emacs

Can someone describe the process that package-autoremove goes through to
create the list of packages that are "safe" to be removed?  When I use
it, I see a few packages that I have connected to other packages
(ex. 'diminish being used by 'use-package).  Is there anything I should
do to signal to package-autoremove that I know a package is needed?

-- 
David Masterson



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-22  4:00 package-autoremove ? David Masterson
@ 2023-08-22 12:17 ` Rudolf Schlatte
  2023-08-25  4:52   ` David Masterson
  0 siblings, 1 reply; 13+ messages in thread
From: Rudolf Schlatte @ 2023-08-22 12:17 UTC (permalink / raw)
  To: help-gnu-emacs

David Masterson <dsmasterson@gmail.com> writes:

> Can someone describe the process that package-autoremove goes through to
> create the list of packages that are "safe" to be removed?  When I use
> it, I see a few packages that I have connected to other packages
> (ex. 'diminish being used by 'use-package).  Is there anything I should
> do to signal to package-autoremove that I know a package is needed?

You can add these packages to `package-selected-packages'.  `M-x
list-packages' will show such packages as "dependency" instead of
"installed"; typing "i" then "x" on the line of a dependency package
(i.e., trying to install the package) will add it to
`package-selected-packages' as well.

For me, this situation comes up when I install a package via
`(use-package ... :ensure t)' instead of via `list-packages'.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-22 12:17 ` Rudolf Schlatte
@ 2023-08-25  4:52   ` David Masterson
  2023-08-25  7:38     ` Philip Kaludercic
  0 siblings, 1 reply; 13+ messages in thread
From: David Masterson @ 2023-08-25  4:52 UTC (permalink / raw)
  To: Rudolf Schlatte; +Cc: help-gnu-emacs

Rudolf Schlatte <rudi@constantly.at> writes:

> David Masterson <dsmasterson@gmail.com> writes:
>
>> Can someone describe the process that package-autoremove goes through to
>> create the list of packages that are "safe" to be removed?  When I use
>> it, I see a few packages that I have connected to other packages
>> (ex. 'diminish being used by 'use-package).  Is there anything I should
>> do to signal to package-autoremove that I know a package is needed?
>
> You can add these packages to `package-selected-packages'.  `M-x
> list-packages' will show such packages as "dependency" instead of
> "installed"; typing "i" then "x" on the line of a dependency package
> (i.e., trying to install the package) will add it to
> `package-selected-packages' as well.
>
> For me, this situation comes up when I install a package via
> `(use-package ... :ensure t)' instead of via `list-packages'.

Sounds like a good possibility for me as well.  Someone should adjust
use-package to add the package to package-selected-packages for this
reason.  My Lisp isn't that good.

-- 
David Masterson



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-25  4:52   ` David Masterson
@ 2023-08-25  7:38     ` Philip Kaludercic
  2023-08-25  8:40       ` Tassilo Horn
  2023-08-26  1:50       ` David Masterson
  0 siblings, 2 replies; 13+ messages in thread
From: Philip Kaludercic @ 2023-08-25  7:38 UTC (permalink / raw)
  To: David Masterson; +Cc: Rudolf Schlatte, help-gnu-emacs

David Masterson <dsmasterson@gmail.com> writes:

> Rudolf Schlatte <rudi@constantly.at> writes:
>
>> David Masterson <dsmasterson@gmail.com> writes:
>>
>>> Can someone describe the process that package-autoremove goes through to
>>> create the list of packages that are "safe" to be removed?  When I use
>>> it, I see a few packages that I have connected to other packages
>>> (ex. 'diminish being used by 'use-package).  Is there anything I should
>>> do to signal to package-autoremove that I know a package is needed?
>>
>> You can add these packages to `package-selected-packages'.  `M-x
>> list-packages' will show such packages as "dependency" instead of
>> "installed"; typing "i" then "x" on the line of a dependency package
>> (i.e., trying to install the package) will add it to
>> `package-selected-packages' as well.
>>
>> For me, this situation comes up when I install a package via
>> `(use-package ... :ensure t)' instead of via `list-packages'.
>
> Sounds like a good possibility for me as well.  Someone should adjust
> use-package to add the package to package-selected-packages for this
> reason.  My Lisp isn't that good.

The :ensure keyword for use-package should select the packages, since it
invokes `package-install' without setting the optional DONT-SELECT
argument (use-package-ensure.el):

--8<---------------cut here---------------start------------->8---
...
                (if (assoc package package-archive-contents)
                    (package-install package)
                  (package-refresh-contents)
                  (when (assoc package (bound-and-true-p
                                        package-pinned-packages))
                    (package-read-all-archive-contents))
                  (package-install package))
...
--8<---------------cut here---------------end--------------->8---

What might be an issue, is that package-install tries to save the
modification of `package-selected-packages' to disk (package.el):

--8<---------------cut here---------------start------------->8---
  (if after-init-time
      (customize-save-variable 'package-selected-packages package-selected-packages)
    (add-hook 'after-init-hook #'package--save-selected-packages))
--8<---------------cut here---------------end--------------->8---

Now if you have customised `custom-file' and/or don't load the contents
of the file, then upon restarting Emacs the updated value would be lost
and package-autoremove would suggest removing all the packages installed
by use-package (but also package-install, for that matter).



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-25  7:38     ` Philip Kaludercic
@ 2023-08-25  8:40       ` Tassilo Horn
  2023-08-25  8:54         ` Philip Kaludercic
  2023-08-26  1:50       ` David Masterson
  1 sibling, 1 reply; 13+ messages in thread
From: Tassilo Horn @ 2023-08-25  8:40 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: David Masterson, Rudolf Schlatte, help-gnu-emacs

Philip Kaludercic <philipk@posteo.net> writes:

Hi Philip,

>>> For me, this situation comes up when I install a package via
>>> `(use-package ... :ensure t)' instead of via `list-packages'.
>>
>> Sounds like a good possibility for me as well.  Someone should adjust
>> use-package to add the package to package-selected-packages for this
>> reason.  My Lisp isn't that good.
>
> The :ensure keyword for use-package should select the packages, since
> it invokes `package-install' without setting the optional DONT-SELECT
> argument (use-package-ensure.el):
>
> --8<---------------cut here---------------start------------->8---
> ...
>                 (if (assoc package package-archive-contents)
>                     (package-install package)
>                   (package-refresh-contents)
>                   (when (assoc package (bound-and-true-p
>                                         package-pinned-packages))
>                     (package-read-all-archive-contents))
>                   (package-install package))
> ...
> --8<---------------cut here---------------end--------------->8---
>
> What might be an issue, is that package-install tries to save the
> modification of `package-selected-packages' to disk (package.el):
>
> --8<---------------cut here---------------start------------->8---
>   (if after-init-time
>       (customize-save-variable 'package-selected-packages package-selected-packages)
>     (add-hook 'after-init-hook #'package--save-selected-packages))
> --8<---------------cut here---------------end--------------->8---
>
> Now if you have customised `custom-file' and/or don't load the
> contents of the file, then upon restarting Emacs the updated value
> would be lost and package-autoremove would suggest removing all the
> packages installed by use-package (but also package-install, for that
> matter).

Very good analysis.  I'm also affected by that issue and indeed, I have
customized custom-file, because I use the very same user-init-file on
multiple machines but put minor machine-related tweaks in custom-file.
Basically, my user-init-file starts with:

--8<---------------cut here---------------start------------->8---
(setopt custom-file (expand-file-name
                     "custom.el"
                     (if user-init-file
                         (file-name-directory user-init-file)
                       "~/.emacs.d/")))
(load custom-file t)
--8<---------------cut here---------------end--------------->8---

Now on two machines which should have pretty much the same emacs setup
(pretty current git master with the same init.el containing the same
use-package with :ensure t statements), package-autoremove suggests
different removal sets.  The union of both sets contains many packages
installed by use-package which are certainly wrong.

It would be great if that could be fixed.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-25  8:40       ` Tassilo Horn
@ 2023-08-25  8:54         ` Philip Kaludercic
  2023-08-25  8:56           ` Tassilo Horn
  0 siblings, 1 reply; 13+ messages in thread
From: Philip Kaludercic @ 2023-08-25  8:54 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: David Masterson, Rudolf Schlatte, help-gnu-emacs

Tassilo Horn <tsdh@gnu.org> writes:

}> Philip Kaludercic <philipk@posteo.net> writes:
>
> Hi Philip,
>
>>>> For me, this situation comes up when I install a package via
>>>> `(use-package ... :ensure t)' instead of via `list-packages'.
>>>
>>> Sounds like a good possibility for me as well.  Someone should adjust
>>> use-package to add the package to package-selected-packages for this
>>> reason.  My Lisp isn't that good.
>>
>> The :ensure keyword for use-package should select the packages, since
>> it invokes `package-install' without setting the optional DONT-SELECT
>> argument (use-package-ensure.el):
>>
>> --8<---------------cut here---------------start------------->8---
>> ...
>>                 (if (assoc package package-archive-contents)
>>                     (package-install package)
>>                   (package-refresh-contents)
>>                   (when (assoc package (bound-and-true-p
>>                                         package-pinned-packages))
>>                     (package-read-all-archive-contents))
>>                   (package-install package))
>> ...
>> --8<---------------cut here---------------end--------------->8---
>>
>> What might be an issue, is that package-install tries to save the
>> modification of `package-selected-packages' to disk (package.el):
>>
>> --8<---------------cut here---------------start------------->8---
>>   (if after-init-time
>>       (customize-save-variable 'package-selected-packages package-selected-packages)
>>     (add-hook 'after-init-hook #'package--save-selected-packages))
>> --8<---------------cut here---------------end--------------->8---
>>
>> Now if you have customised `custom-file' and/or don't load the
>> contents of the file, then upon restarting Emacs the updated value
>> would be lost and package-autoremove would suggest removing all the
>> packages installed by use-package (but also package-install, for that
>> matter).
>
> Very good analysis.  I'm also affected by that issue and indeed, I have
> customized custom-file, because I use the very same user-init-file on
> multiple machines but put minor machine-related tweaks in custom-file.
> Basically, my user-init-file starts with:
>
> (setopt custom-file (expand-file-name
>                      "custom.el"
>                      (if user-init-file
>                          (file-name-directory user-init-file)
>                        "~/.emacs.d/")))

What is the point of this check?  FWIW my init.el starts with

  (load (setq custom-file (locate-user-emacs-file "custom.el")) t)

and I have never had issues with it.

> (load custom-file t)

> Now on two machines which should have pretty much the same emacs setup
> (pretty current git master with the same init.el containing the same
> use-package with :ensure t statements), package-autoremove suggests
> different removal sets.  The union of both sets contains many packages
> installed by use-package which are certainly wrong.

I have little to no experience with use-package, so I am not the best
person to help here.  Have you reported this behaviour as a bug?

> It would be great if that could be fixed.
>
> Bye,
> Tassilo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-25  8:54         ` Philip Kaludercic
@ 2023-08-25  8:56           ` Tassilo Horn
  2023-08-25 12:58             ` Tassilo Horn
  0 siblings, 1 reply; 13+ messages in thread
From: Tassilo Horn @ 2023-08-25  8:56 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: David Masterson, Rudolf Schlatte, help-gnu-emacs

Philip Kaludercic <philipk@posteo.net> writes:

Hi Philip,

>> (setopt custom-file (expand-file-name
>>                      "custom.el"
>>                      (if user-init-file
>>                          (file-name-directory user-init-file)
>>                        "~/.emacs.d/")))
>
> What is the point of this check?

When emacs runs with -batch, user-init-file is nil and my system-update
script contains an emacs package update step running

  emacs -batch -l ~/.emacs.d/init.el -f package-upgrade-all

> FWIW my init.el starts with
>
>   (load (setq custom-file (locate-user-emacs-file "custom.el")) t)
>
> and I have never had issues with it.

I'll try if that also works with -batch.  Thanks!

>> (load custom-file t)
>
>> Now on two machines which should have pretty much the same emacs setup
>> (pretty current git master with the same init.el containing the same
>> use-package with :ensure t statements), package-autoremove suggests
>> different removal sets.  The union of both sets contains many packages
>> installed by use-package which are certainly wrong.
>
> I have little to no experience with use-package, so I am not the best
> person to help here.  Have you reported this behaviour as a bug?

Not yet but I'll do so.

Bye,
Tassilo




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-25  8:56           ` Tassilo Horn
@ 2023-08-25 12:58             ` Tassilo Horn
  2023-08-26  2:01               ` David Masterson
  0 siblings, 1 reply; 13+ messages in thread
From: Tassilo Horn @ 2023-08-25 12:58 UTC (permalink / raw)
  To: Philip Kaludercic, David Masterson, Rudolf Schlatte,
	help-gnu-emacs

Tassilo Horn <tsdh@gnu.org> writes:

> When emacs runs with -batch, user-init-file is nil and my system-update
> script contains an emacs package update step running
>
>   emacs -batch -l ~/.emacs.d/init.el -f package-upgrade-all
>
>> FWIW my init.el starts with
>>
>>   (load (setq custom-file (locate-user-emacs-file "custom.el")) t)
>>
>> and I have never had issues with it.
>
> I'll try if that also works with -batch.  Thanks!

Yup, that seems to work just as well.

>> I have little to no experience with use-package, so I am not the best
>> person to help here.  Have you reported this behaviour as a bug?
>
> Not yet but I'll do so.

Well, I cannot reproduce the issue from a fresh start, that is, after
deleting ~/.emacs.d/elpa/ and ~/.emacs.d/custom.el.  When I start emacs
then, all packages of (use-package ... :ensure t) recipes are installed.
When I restart emacs, package-selected-packages looks good and
package-autoremove doesn't suggest anything.

But I was in the "package-autoremove suggests use-package-installed
packages" situations many times.  Not sure how I ended up there.

Anyway, as long as I cannot reproduce the issue, I won't report a bug.
David, can you reproduce the issue?

BTW: When trying around with a minimal init.el on a testuser account, I
found the small issue that package-delete-ing the very last installed
package will keep it in package-selected-packages because
package--save-selected-packages doesn't save when the optional argument
"value" is nil.  Of course, an optional argument can be nil if not
provided or nil when the given arguments values is nil...

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-25  7:38     ` Philip Kaludercic
  2023-08-25  8:40       ` Tassilo Horn
@ 2023-08-26  1:50       ` David Masterson
  2023-08-26 12:03         ` Philip Kaludercic
  1 sibling, 1 reply; 13+ messages in thread
From: David Masterson @ 2023-08-26  1:50 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Rudolf Schlatte, help-gnu-emacs

Philip Kaludercic <philipk@posteo.net> writes:

> The :ensure keyword for use-package should select the packages, since it
> invokes `package-install' without setting the optional DONT-SELECT
> argument (use-package-ensure.el):
>
> ...
>                 (if (assoc package package-archive-contents)
>                     (package-install package)
>                   (package-refresh-contents)
>                   (when (assoc package (bound-and-true-p
>                                         package-pinned-packages))
>                     (package-read-all-archive-contents))
>                   (package-install package))
> ...
>
>
> What might be an issue, is that package-install tries to save the
> modification of `package-selected-packages' to disk (package.el):

Save it to "custom-file" which might be nil (.emacs).  Didn't know about
custom-file... 

>   (if after-init-time
>       (customize-save-variable 'package-selected-packages
>                                package-selected-packages)
>     (add-hook 'after-init-hook #'package--save-selected-packages))
>
> Now if you have customised `custom-file' and/or don't load the contents
> of the file, then upon restarting Emacs the updated value would be lost
> and package-autoremove would suggest removing all the packages installed
> by use-package (but also package-install, for that matter).

What happens if custom-file (.emacs) is already loaded in a buffer?  I
thought, if you customize something (via the GUI?), the custom-file
(.emacs) would be loaded into a buffer (unless it's already in a buffer)
and the custom-variables would be updated.  When you exit Emacs, the
file would be saved.

-- 
David Masterson



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-25 12:58             ` Tassilo Horn
@ 2023-08-26  2:01               ` David Masterson
  0 siblings, 0 replies; 13+ messages in thread
From: David Masterson @ 2023-08-26  2:01 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Philip Kaludercic, Rudolf Schlatte, help-gnu-emacs

Tassilo Horn <tsdh@gnu.org> writes:

> Tassilo Horn <tsdh@gnu.org> writes:
>
>
> Well, I cannot reproduce the issue from a fresh start, that is, after
> deleting ~/.emacs.d/elpa/ and ~/.emacs.d/custom.el.  When I start emacs
> then, all packages of (use-package ... :ensure t) recipes are installed.
> When I restart emacs, package-selected-packages looks good and
> package-autoremove doesn't suggest anything.
>
> But I was in the "package-autoremove suggests use-package-installed
> packages" situations many times.  Not sure how I ended up there.
>
> Anyway, as long as I cannot reproduce the issue, I won't report a bug.
> David, can you reproduce the issue?

Not yet.  I'll have to think about what Phil said to see if I can think
of one.  My environment seems similar to yours in that I'm trying to use
use-package to know what needs to be installed in a fresh installation,
I've been relying, though, on package-list-packages too much to find
things to install.  Perhaps that's confused things.

Thanks all for the ideas...

-- 
David Masterson



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: package-autoremove ?
  2023-08-26  1:50       ` David Masterson
@ 2023-08-26 12:03         ` Philip Kaludercic
  0 siblings, 0 replies; 13+ messages in thread
From: Philip Kaludercic @ 2023-08-26 12:03 UTC (permalink / raw)
  To: David Masterson; +Cc: Rudolf Schlatte, help-gnu-emacs

David Masterson <dsmasterson@gmail.com> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> The :ensure keyword for use-package should select the packages, since it
>> invokes `package-install' without setting the optional DONT-SELECT
>> argument (use-package-ensure.el):
>>
>> ...
>>                 (if (assoc package package-archive-contents)
>>                     (package-install package)
>>                   (package-refresh-contents)
>>                   (when (assoc package (bound-and-true-p
>>                                         package-pinned-packages))
>>                     (package-read-all-archive-contents))
>>                   (package-install package))
>> ...
>>
>>
>> What might be an issue, is that package-install tries to save the
>> modification of `package-selected-packages' to disk (package.el):
>
> Save it to "custom-file" which might be nil (.emacs).  Didn't know about
> custom-file... 
>
>>   (if after-init-time
>>       (customize-save-variable 'package-selected-packages
>>                                package-selected-packages)
>>     (add-hook 'after-init-hook #'package--save-selected-packages))
>>
>> Now if you have customised `custom-file' and/or don't load the contents
>> of the file, then upon restarting Emacs the updated value would be lost
>> and package-autoremove would suggest removing all the packages installed
>> by use-package (but also package-install, for that matter).
>
> What happens if custom-file (.emacs) is already loaded in a buffer?  I
> thought, if you customize something (via the GUI?), the custom-file
> (.emacs) would be loaded into a buffer (unless it's already in a buffer)
> and the custom-variables would be updated.  When you exit Emacs, the
> file would be saved.

That should be the case.  You can experiment with this yourself using
`customize-save-variable'.

-- 
Philip Kaludercic



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-08-26 12:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-22  4:00 package-autoremove ? David Masterson
2023-08-22 12:17 ` Rudolf Schlatte
2023-08-25  4:52   ` David Masterson
2023-08-25  7:38     ` Philip Kaludercic
2023-08-25  8:40       ` Tassilo Horn
2023-08-25  8:54         ` Philip Kaludercic
2023-08-25  8:56           ` Tassilo Horn
2023-08-25 12:58             ` Tassilo Horn
2023-08-26  2:01               ` David Masterson
2023-08-26  1:50       ` David Masterson
2023-08-26 12:03         ` Philip Kaludercic
  -- strict thread matches above, loose matches on Subject: below --
2020-09-03  4:35 David Masterson
2020-09-03  6:38 ` Pankaj Jangid

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