unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Use package-vc.el for declarative, source-based package management?
@ 2024-04-15  9:51 Mekeor Melire
  2024-04-15 12:29 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-04-15 19:45 ` Philip Kaludercic
  0 siblings, 2 replies; 3+ messages in thread
From: Mekeor Melire @ 2024-04-15  9:51 UTC (permalink / raw)
  To: help-gnu-emacs

Hello :)

I'm trying to use Emacs' built-in package-vc.el for an opinionated way
of declarative, source-based package management. I use Emacs from master
branch and I would like to use some Elpa-packages from their respective
development branch too. I also want local checkouts of their
repositories so that I can quickly contribute to them. And I do not want
to use Emacs' built-in use-package.el. Ideally, my init.el would begin
like this:

  ;; Here, I'd maintain a list of packages that I want to be installed:
  (setopt package-vc-...-list-of-packages '(consult embark vertico))

  ;; Then I'd instruct package-vc.el to ensure that these packages are
  ;; installed, i.e. install missing packages with local repo
  ;; checkouts:
  (package-vc-...-ensure)

But so far, I was only able to approximate this ideal with several
caveats in my init.el, as follows. First, I load relevant modules.

  (require 'package)
  (require 'package-vc)

Here I maintain a list of packages that I want to be installed.

  (setopt package-vc-selected-packages
    '( (consult
         :url "https://github.com/minad/consult.git")
       (embark
         :url "https://github.com/oantolin/embark.git"
         :ignored-files ("embark-consult.el" "avy-embark-collect.el"))
       (vertico
         :url "https://github.com/minad/vertico.git")
       (vertico-buffer
         :url "https://github.com/minad/vertico.git"
         :lisp-dir "extensions"
         :main-file "vertico-buffer.el")))

As you can see, one caveat is that I need to specify :url, :lisp-dir and
similar values manually. Can I gather these somehow automatically
instead?

Another caveat is that some repositories, like Vertico's, contain
multiple packages, like vertico-buffer. Can I avoid having multiple
local checkouts of the same repository (while still keeping all
(sub)packages marked as installed)?

Now, I'd like to ensure that these packages are installed. But if I put
(package-vc-install-selected-packages) in my init.el, Emacs
interactively asks me "Overwrite previous checkout for package
`consult'? (yes or no)" during startup. That's why I currently evaluate
that s-expression manually whenever I change the value of
package-vc-selected-packages. Is there a way to to make
package-vc-install-selected-packages (1.) not ask anything
interactively; and (2.) simply not overwrite already installed packages;
and (3.) still install packages that not yet installed?

After having ensured that packages are installed, the following
initializes load-path:

  (package-initialize)

There's another problem though: When I put a package foo in
package-vc-selected-packages, and foo depends on another external
package bar, and I have not put bar in -selected-packages, and I call
package-vc-install-selected-packages, then Emacs will try to install to
install bar from a package-archive without any local repository checkout
but rather in the usual package.el way. That's why I also have this
setting in my init.el:

  (setopt package-archives nil)

This forces package.el to fail when I forgot to list a dependency in
-selected-packages variable. As an unfortunate consequence, I also end
up doing dependency management manually. But I'd love to have
dependencies vc-installed too! Thus this question arises: Is there a way
to tell package-vc-install-selected-packages to vc-install the selected
packages *including* their dependencies?



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

* Re: Use package-vc.el for declarative, source-based package management?
  2024-04-15  9:51 Use package-vc.el for declarative, source-based package management? Mekeor Melire
@ 2024-04-15 12:29 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2024-04-15 19:45 ` Philip Kaludercic
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-04-15 12:29 UTC (permalink / raw)
  To: help-gnu-emacs

> After having ensured that packages are installed, the following
> initializes load-path:
>
>   (package-initialize)

This does a whole lot more than initialize `load-path`.
More importantly, this is a function which you should never need to
call (it's called automatically by other functions, as needed).

What you should generally call instead is `package-activate-all`.

If you find it necessary to call `package-initialize`, please report it
as a bug.


        Stefan




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

* Re: Use package-vc.el for declarative, source-based package management?
  2024-04-15  9:51 Use package-vc.el for declarative, source-based package management? Mekeor Melire
  2024-04-15 12:29 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2024-04-15 19:45 ` Philip Kaludercic
  1 sibling, 0 replies; 3+ messages in thread
From: Philip Kaludercic @ 2024-04-15 19:45 UTC (permalink / raw)
  To: Mekeor Melire; +Cc: help-gnu-emacs

Mekeor Melire <mekeor@posteo.de> writes:

> Hello :)
>
> I'm trying to use Emacs' built-in package-vc.el for an opinionated way
> of declarative, source-based package management. I use Emacs from master
> branch and I would like to use some Elpa-packages from their respective
> development branch too. I also want local checkouts of their
> repositories so that I can quickly contribute to them. And I do not want
> to use Emacs' built-in use-package.el. Ideally, my init.el would begin
> like this:
>
>   ;; Here, I'd maintain a list of packages that I want to be installed:
>   (setopt package-vc-...-list-of-packages '(consult embark vertico))
>
>   ;; Then I'd instruct package-vc.el to ensure that these packages are
>   ;; installed, i.e. install missing packages with local repo
>   ;; checkouts:
>   (package-vc-...-ensure)
>
>
> But so far, I was only able to approximate this ideal with several
> caveats in my init.el, as follows. First, I load relevant modules.
>
>   (require 'package)
>   (require 'package-vc)
>
> Here I maintain a list of packages that I want to be installed.
>
>   (setopt package-vc-selected-packages
>     '( (consult
>          :url "https://github.com/minad/consult.git")
>        (embark
>          :url "https://github.com/oantolin/embark.git"
>          :ignored-files ("embark-consult.el" "avy-embark-collect.el"))
>        (vertico
>          :url "https://github.com/minad/vertico.git")
>        (vertico-buffer
>          :url "https://github.com/minad/vertico.git"
>          :lisp-dir "extensions"
>          :main-file "vertico-buffer.el")))
>
> As you can see, one caveat is that I need to specify :url, :lisp-dir and
> similar values manually. Can I gather these somehow automatically
> instead?

ELPA should already provide this information.

> Another caveat is that some repositories, like Vertico's, contain
> multiple packages, like vertico-buffer. Can I avoid having multiple
> local checkouts of the same repository (while still keeping all
> (sub)packages marked as installed)?

Not really, by checking out repositories directly and adding their
directories to `load-path' there are certain restrictions.  Usually this
is best fixed upstream.

> Now, I'd like to ensure that these packages are installed. But if I put
> (package-vc-install-selected-packages) in my init.el, Emacs
> interactively asks me "Overwrite previous checkout for package
> `consult'? (yes or no)" during startup. That's why I currently evaluate
> that s-expression manually whenever I change the value of
> package-vc-selected-packages. Is there a way to to make
> package-vc-install-selected-packages (1.) not ask anything
> interactively; and (2.) simply not overwrite already installed packages;
> and (3.) still install packages that not yet installed?

In the current state, `package-vc-install-selected-packages' should be
marked as interactive-only, since this kind of usage just isn't
reasonably supported, as you point out.  We should perhaps add a
NOCONFORM argument, like what `package-install-selected-packages' has.

> After having ensured that packages are installed, the following
> initializes load-path:
>
>   (package-initialize)
>
> There's another problem though: When I put a package foo in
> package-vc-selected-packages, and foo depends on another external
> package bar, and I have not put bar in -selected-packages, and I call
> package-vc-install-selected-packages, then Emacs will try to install to
> install bar from a package-archive without any local repository checkout
> but rather in the usual package.el way. 

That is because package-vc is never meant to be a replacement for
package.el or the default way of installing things.  One should
emphasise, that from-source package management has the downside of
increasing the complexity of upgrading and that one might always land on
an unreliable commit that the author never meant to publish.

>                                         That's why I also have this
> setting in my init.el:
>
>   (setopt package-archives nil)
>
> This forces package.el to fail when I forgot to list a dependency in
> -selected-packages variable. As an unfortunate consequence, I also end
> up doing dependency management manually. But I'd love to have
> dependencies vc-installed too! Thus this question arises: Is there a way
> to tell package-vc-install-selected-packages to vc-install the selected
> packages *including* their dependencies?

That would require a modification to `package-vc-install-dependencies',
so that it dosn't call `package-install-from-archive'.  But once again,
I would urge to rethink the approach.  What is the reason you want to
have everything installed using package-vc?  Frequently, I find that
there are some wrong assumptions behind the wish that I hope to clarify.

-- 
	Philip Kaludercic on peregrine



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

end of thread, other threads:[~2024-04-15 19:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-15  9:51 Use package-vc.el for declarative, source-based package management? Mekeor Melire
2024-04-15 12:29 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-04-15 19:45 ` Philip Kaludercic

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