Skip to content

Make install check aware of alternative package managers#1007

Open
matsl wants to merge 5 commits into
masterfrom
package_manager_aware_install_check
Open

Make install check aware of alternative package managers#1007
matsl wants to merge 5 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 Outdated
@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 Outdated
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
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.

@matsl
matsl force-pushed the package_manager_aware_install_check branch 2 times, most recently from ce976bd to b4f668b Compare July 16, 2026 13:05
@rswgnu

rswgnu commented Jul 16, 2026

Copy link
Copy Markdown
Owner

I don't understand your reference to denote here. Could you explain or point me to some other message you are referring to. I do see that the latest merge build here failed on 28.2. Are you fixing that?

@matsl

matsl commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

@rswgnu Removing the nongnu archive insertion that we talked about yesterday did not work. Reason was that in one call path the whole package-archives was locally set to nil. I suppose for not tampering with users package-archives. I had missed that. So I inserted that back but slightly different. As we said yesterday we possibly can remove this juggling since with nongnu being the default we could just try to install. However I did not want to do that in this long and winding PR. Happy to work on that in a separate PR though.

I also added unit tests for the new functions.

Since the PR had many commits I squashed it and tried to make a better ChangeLog for the changes.

PTAL.

Comment thread test/hypb-tests.el Outdated
Comment thread hypb.el Outdated
Comment thread hypb.el Outdated
Comment thread hypb.el Outdated
Comment thread test/hy-test-dependencies.el Outdated
@rswgnu

rswgnu commented Jul 16, 2026 via email

Copy link
Copy Markdown
Owner

Comment thread test/hy-test-dependencies.el
@matsl

matsl commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

If you are just going to rely on default behavior, I would deal with that now and then have your tests cover it,

Well, I don't think the tests need any change. It is two line change and all tests works when I tried it. I can push it so you can review.

@matsl
matsl force-pushed the package_manager_aware_install_check branch from 953f69c to 87790f1 Compare July 16, 2026 21:52
@matsl

matsl commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

I don't understand your reference to denote here.

I understood it as you said you were pausing adding the dynamic install check for denote until this PR was merged so you would not make this work harder. Rather to be able to use hybp:install-package directly when it was ready. Maybe I misunderstood.

@matsl
matsl requested a review from rswgnu July 16, 2026 21:58
@matsl

matsl commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

Don't know if we can trust this but this time the build worked for all versions. PTAL

@rswgnu

rswgnu commented Jul 16, 2026

Copy link
Copy Markdown
Owner

I approved so you can merge when you have time to test.

matsl added 4 commits July 17, 2026 09:04
Try to identify when user does not use the default package.el and then
fall back to notify users a manual install of a dynamic dependency is
neeed. Do also ask a user that uses the packet.el before doing the
default, customizable to not ask.

* test/hy-test-helpers.el (hy-test-mocked-feature): Macro for mocking
    featurep.

* test/hypb-tests.el (hypb--users-package-manager):
    (hypb--package-el-install):
    (hypb--notify-manual-install-needed):
    (hypb--ensure-dependency):
    (hypb--require-package):  Unit tests for the new functions.

* test/hy-test-dependencies.el (hypb:ask-to-install-package-flag): Set to
    nil for not asking about installing dynamic dependencies during test,
    i.e. markdown-mode.

* 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): Use require to check if
    markdown-mode is available. Ensure package-archives is set to nongnu
    for markdown-mode install. Moved out from
    hyrolo-install-markdown-mode.
    (hyrolo-markdown-mode): Remove not needed require.
    (hyrolo-install-markdown-mode): Use hypb:require-package.

* hypb.el (hypb:ask-to-install-package-flag): 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.
If user has removed nongnu and use the default package manager an
install error will notify user that markdown mode is needed.
@matsl
matsl force-pushed the package_manager_aware_install_check branch from 87790f1 to b86dfe8 Compare July 17, 2026 07:06
In CI we are seeing odd internal errors due to wrong-type-argument in
package.el. This adds an advice to retry this case. It is applied as a
band aid to unblock CI for now on this issue.

* test/hy-test-dependencies.el (hypb:package-install-advice-for-retry):
Advice for retrying package-install.
@matsl

matsl commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator Author

@rswgnu This was the least intrusive change I could come up with. package-install is adviced to retry on the specific error that we get. It is only applied for version 32.0.50 i.e will only matter for CI build and those who build their Emacs from source. And it is only applied in the unit tests when hy-test-dependencies is loaded.

Slightly sad things is that with this advice the error has never occurred. It is like Heisenberg's indeterminacy principle. If we try to catch the error it is gone.

I know the PR is approved but want you view on this way to move forward since that was added after the approval.

@matsl
matsl requested a review from rswgnu July 18, 2026 16:13
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