Skip to content

Make install check aware of alternative package managers#1007

Open
matsl wants to merge 6 commits into
masterfrom
package_manager_aware_install_check
Open

Make install check aware of alternative package managers#1007
matsl wants to merge 6 commits into
masterfrom
package_manager_aware_install_check

Conversation

@matsl

@matsl matsl commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

What

Make install check aware of alternative package managers and avoid doing
package-install for those. Adding a defcustom so users can choose to get an
automated install if using the standard package.el.

Why

There are multiple package managers so we can't assume users use
package.el. If it is not used then using it to install a package would likely
be an error an could damage a users setup or at least not be what the user
expects.

Supporting different package managers for an automatic install is beyond
where we want to go.

Note

The idea is to use hypb:ensure-dependency in all places where we today to package-install-p. That would be

$ grep package-installed-p *.el
hsys-consult.el:  (unless (package-installed-p 'consult)
hsys-consult.el:  (unless (package-installed-p 'org-roam)
hui-treemacs.el:    (and (package-installed-p 'treemacs)
hypb.el:  (unless (package-installed-p 'interaction-log)
hypb.el:           (package-installed-p package))
hyrolo.el:    (unless (package-installed-p 'markdown-mode)
hyrolo.el:  (unless (package-installed-p 'markdown-mode)

Before implementing that could you, @rswgnu, take a look at what you think of
using this idea? If that makes sense I can complete this Draft.

@matsl matsl requested a review from rswgnu July 11, 2026 14:03

@rswgnu rswgnu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are on the right track. I would finish it off and add quelpa.

Comment thread hypb.el
(defun hypb:users-package-manager ()
"Return the package manager in use.
Current supported package managers are `straight', `elpaca', and `package'."
(cond ((and (featurep 'straight) (fboundp 'straight-use-package)) 'straight)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add quelpa too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read up on quelpa and it seems it is based on top of package.el. Users can mix installing using quelpa and package.el directly. So it is not clear a user would prefer to install the packages we dynamically depend on using quelpa. So we can let package.el handle a potential install for quelpa users. It will not cause any big problem for them if I understand things correctly.

@matsl matsl force-pushed the package_manager_aware_install_check branch from 754e1c6 to 01440cb Compare July 12, 2026 21:06
@matsl matsl marked this pull request as ready for review July 12, 2026 21:19
@matsl matsl requested a review from rswgnu July 12, 2026 21:19
Comment thread hyrolo.el
Comment on lines +3232 to +3242
(or (require 'markdown-mode nil t)
(pcase (hypb:users-package-manager)
('package (when (or (not hypb:dependency-install-ask)
(y-or-n-p (format "Install `%s' to enable this feature? " 'markdown-mode)))
(unless (assoc "nongnu" package-archives)
(setq package-archives (cl-copy-list package-archives))
(add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/")
t))
(package-refresh-contents)
(package-install 'markdown-mode)))
(manager (hypb:notify-manual-install-needed 'markdown-mode manager)))))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implemented on its own to allow the insertion of nongnu if that is missing only in the case where package.el is used. An alternative would be to do that either always or if package.el is in use and then call hypb:require-package. Seeing it now it might more sense to do like that. WDYT?

Comment thread hyrolo.el
rswgnu
rswgnu previously approved these changes Jul 13, 2026

@rswgnu rswgnu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see together if we can reduce the number of these added support functions before merging this. We can go through it together when you have time.

Comment thread hypb.el Outdated
@rswgnu rswgnu dismissed their stale review July 13, 2026 15:08

Mistakenly approved.

@matsl

matsl commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

Let's see together if we can reduce the number of these added support functions before merging this. We can go through it together when you have time.

What functions do you think makes sense to merge? Do you think the number of functions makes the code hard to understand?

@matsl matsl requested a review from rswgnu July 13, 2026 19:01
@rswgnu

rswgnu commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Just felt like a lot of functions when I first looked at it. I'll have to look at it more to figure out where we could merge in consultation with you.

@matsl

matsl commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

Just felt like a lot of functions when I first looked at it. I'll have to look at it more to figure out where we could merge in consultation with you.

There are four new functions. But shall the number of functions matter? Yes, they are small but with a clear purpose. The ChangeLog is a bit hard to read but I tried to get all in there which might make it look more than it is!? Happy talk about it.

matsl added 6 commits July 14, 2026 22:58
* hypb.el (hypb:dependency-install-ask): Give user control if package
shall be installed when using package.el.
(hypb:users-package-manager): Users package manager.
(hypb:package-el-install): Install package using package.el.
(hypb:notify-manual-install-needed): Notify user manual install is needed.
(hypb:ensure-dependency): Ensure package is available using
hypb:package-el-install or hypb:notify-manual-install-needed.
(hypb:require-package): Use hypb:ensure-dependency.
* hsys-consult.el (hsys-consult-require-version):
(hsys-consult--org-roam-call-function):
* hui-treemacs.el (treemacs):
* hypb.el (hypb:activate-interaction-log-mode): Use hypb:require-package.
* hyrolo.el (hyrolo-any-file-type-problem-p): User require to check if
markdown-mode is available.
(hyrolo-install-markdown-mode): Copy hypb:ensure-dependency but add
nongnu if is missing to package-archives before installation.
* hyrolo.el (hyrolo-install-markdown-mode): Ask user for install of
markdown-mode.
* test/hy-test-dependencies.el (hypb:dependency-install-ask): Set to
nil for not asking about installing dynamic dependencies during test,
i.e. markdown-mode.
@matsl matsl force-pushed the package_manager_aware_install_check branch from 69b4a85 to 27e61c3 Compare July 14, 2026 21:01
@matsl

matsl commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

@rswgnu I've rebased it so it is possible to merge it so it will be possible for you to add require of denote if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants