emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [package-vc] Consider cleaning up files from install process


From: Adam Porter
Subject: Re: [package-vc] Consider cleaning up files from install process
Date: Sat, 7 Oct 2023 02:52:34 -0500
User-agent: Mozilla Thunderbird

Hi Philip,

On 9/20/23 03:13, Philip Kaludercic wrote:

IMHO that seems like a sort of user-error, to leave uncommitted
changes in a repo that's under the control of a system that doesn't
take such changes into account when operating on the repo.  IOW, if I
install a package with command package-FOO, I expect the files it
makes to be under its purview, not mine; they are not my personal data
files, but belong to Emacs and its package.el library, the same as if
I used "M-x package-install".

I don't believe in these kinds of distinctions.  I can change what I
want, the only question I have to keep in mind is what the chances of
loosing these changes is going to be.

I think I understand what you mean. However, that seems to conflict with the idea of loading packages directly from git worktrees, regardless of their status. That is, when I install a package into my Emacs configuration, I intend for the version I installed to be available when I start Emacs, not whatever state I might have left the repository in when I last touched it. If I had last checked out an in-progress feature branch and then shut down my computer, I wouldn't want Emacs to attempt to load that next time.

To put it another way, it seems like a bit of an anti-pattern to
develop a package that's stored in "~/.emacs.d/elpa"--that directory
is supposed to be for installed packages' files, and it should be safe
to wipe that directory out at any time and reinstall packages from
their sources--after all,

Is that documented anywhere?  I know it can be done, if your
configuration is written accordingly, but if you see installed packages
as not being part of your domain, then transgressing layers of
abstraction and accessing, then deleting the "internal" representation
of package.el would seem to also be wrong?

I don't know if that idea is documented anywhere, but it seems implicit to me by reason of users not necessarily needing to be aware of what files and directories get created when installing a package. If a user only used the package-install and package-delete commands, and didn't look at the filesystem or messages output, he wouldn't know nor care where the packages' files were. (I regularly advocate committing one's "elpa/" directory to git along with one's "init.el", and in so doing I've learned how many users aren't aware of how it all works.)

Can you describe the interface you are imagining.  From what I
understand, it should be possible to reproduce what you need by
combining `package-vc-checkout' and `package-install-file'?

Well, I would expect it to act similarly to Quelpa:

1. Clone the git repo (shallowly, at least by default) to a directory
(perhaps a temporary one, but at least one stored in the appropriate
XDG cache directory, outside of user-emacs-directory).

2.  Call package-install-file on that worktree.

3.  The package ends up installed into package-user-dir as if it were
installed with package-install from ELPA.

How does this look like:

--8<---------------cut here---------------start------------->8---
(defun package-vc-install-copy (pkg-desc)
   "Fetch the package sources of PKG-DESC and install a copy."
   (interactive (list (package-vc--read-package-desc "Fetch package source: ")))
   (let* ((copy (copy-package-desc pkg-desc))
         (package-dir (expand-file-name
                       (symbol-name (package-desc-name pkg-desc))
                       (make-temp-file "package-vc-" t)))
         (package-vc-register-as-project nil))
     (setf (package-desc-dir copy) package-dir)
     (save-window-excursion
       (package-vc-checkout pkg-desc package-dir)
       (package-install-from-buffer))))
--8<---------------cut here---------------end--------------->8---

I'd ideally pass :last-release to package-vc-checkout, but I have
detected a bug with this setup that should be fixed.

I tested that command in a clean Emacs 29.1, and it seems to work well. Thanks.

The only suggestion I have would be for an optional persistent directory used for keeping the git repositories around as a cache (i.e. outside of user-emacs-directory, likely in $XDG_CACHE_HOME), so that when upgrading the package, the whole repo wouldn't need to be cloned again, e.g. Quelpa configures this in the `quelpa-dir' option.

The main question I have is what advantage or disadvantage this would
provide over Quelpa?  The functionality you describe misses the point of
what I see to be the point of package-vc, as it wasn't written to be a
replacement of Straight or Quelpa (I have never used either of the two),
but just as a tool to streamline fetching and preparing packages
directly from source code repositories.

The advantage over Quelpa would simply be to not require Quelpa. :) I'd like for this functionality to be built-in to Emacs. I thought that's what package-vc was basically intended to do (i.e. give a user a git repo URL and he can install the package into his Emacs with a single command, as if he had cloned it manually and ran package-install on it), but maybe I misunderstood.

Thanks for your help,
Adam



reply via email to

[Prev in Thread] Current Thread [Next in Thread]