unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Adam Porter <adam@alphapapa.net>,
Cc: Joseph Turner <joseph@breatheoutbreathe.in>,
	 Emacs Devel Mailing List <emacs-devel@gnu.org>
Subject: Re: [package-vc] Consider cleaning up files from install process
Date: Sat, 07 Oct 2023 13:31:27 +0000	[thread overview]
Message-ID: <87pm1qpnio.fsf@posteo.net> (raw)
In-Reply-To: <560eeace-6c97-40e2-988b-3b1019f24677@alphapapa.net> (Adam Porter's message of "Sat, 7 Oct 2023 02:52:34 -0500")

Adam Porter <adam@alphapapa.net> writes:

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

It is not that I don't get your argument, I think it is a fair point; my
issue is that this ends up just being a discussion of anecdotal
use-cases.  I can point out that if I check out a feature branch, I
would like to use it, that if I modify a function, I'd like to test it.
If I just want to hack on something that I am not using, I wouldn't be
using package-vc.  But I suspect that this doesn't mean that much to
you, because we just have different workflows.

>>> 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 don't think I agree.  Just because a user doesn't know what "apt
install coreutils" does, doesn't mean that the system should have to be
resilient to a "rm -rf {,/usr{,/local}}/bin".  It would be a different
matter if the user could reasonably assume that elpa/ is a cache
directory, but I don't see why that should be the case.

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

That is something i wouldn't recommend, but mostly because I avoid
adding auto-generated files to a git repository.

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

Currently I wouldn't want to add this to package-vc itself, but I could
imagine adding a package to ELPA that would provide the functionality
with all the related user 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.

The background for package-vc is that it is a further iteration on my
site-lisp package.  I wrote that to automatically manage (add to
`load-path', byte-compile, scrape for autoloads) my packages, that I
load directly from their Git repositories, because I want M-x
find-function to work.  Following Stefan Monnier advice, the approach
with package-vc was to delegate loading the package.el, and add an
alternative "back-end" for fetching packages + means for contributing
local changes back upstream (package-vc-prepare-patch, and why
package-vc-install fetches an index of package specifications from ELPA
servers).  Installing packages that are not listed in GNU or NonGNU ELPA
is neat, but not my focus behind developing the package.  That remains
streamlining the process of contributing to packages and hacking
directly on the code that is being loaded.

> Thanks for your help,
> Adam



  reply	other threads:[~2023-10-07 13:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19  7:24 [package-vc] Consider cleaning up files from install process Joseph Turner
2023-09-19  9:03 ` Philip Kaludercic
2023-09-19 12:19   ` Adam Porter
2023-09-19 13:50     ` Philip Kaludercic
2023-09-19 14:34       ` Adam Porter
2023-09-20  8:13         ` Philip Kaludercic
2023-10-07  7:52           ` Adam Porter
2023-10-07 13:31             ` Philip Kaludercic [this message]
2023-09-20 12:13         ` Stefan Monnier via Emacs development discussions.
2023-09-20 12:08     ` Stefan Monnier via Emacs development discussions.
2023-09-20 12:03 ` Stefan Monnier via Emacs development discussions.
  -- strict thread matches above, loose matches on Subject: below --
2023-10-04  8:11 Joseph Turner
2023-10-04  8:22 Joseph Turner
2023-10-04  8:31 Joseph Turner
2023-10-04 15:23 ` Philip Kaludercic
2023-10-04 18:54   ` Joseph Turner
2023-10-06  9:00     ` Philip Kaludercic

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=87pm1qpnio.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=adam@alphapapa.net \
    --cc=emacs-devel@gnu.org \
    --cc=joseph@breatheoutbreathe.in \
    /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).