New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require-package will not be added to package-selected-packages after first startup #603

Closed
yurimx opened this Issue Aug 28, 2018 · 10 comments

Comments

Projects
None yet
2 participants
@yurimx
Copy link
Contributor

yurimx commented Aug 28, 2018

Hello:

This problem has existed for two years, at least since I started using your configuration (2017).
I took it out again today because I had trouble with this issue recently.

When the first load is completed, if you call require-package in init-local.el, the installed packages will not be logged to package-selected-packages. I accidentally pressed the package-autoremove and uninstalled the packages that were installed later.

Thanks, and sorry for my poor English.

@purcell

This comment has been minimized.

Copy link
Owner

purcell commented Aug 28, 2018

Yep, I've looked at this before and it's really hard to fix. Ultimately I consider package-selected-packages to be a misfeature in package.el.

@purcell

This comment has been minimized.

@yurimx

This comment has been minimized.

Copy link
Contributor Author

yurimx commented Aug 28, 2018

It might have been designed to resemble autoremove in apt.
Some people will always be obsessive disorder.

This problem only occurs when the require-package is called in the file, and not when using eval-last-sexp or other eval function calls.

I have tried some other automatic package installations (including the famous use-package) and found that they don't seem to fit your current configuration. If you use those things, it is basically equivalent to writing a new configuration...

Also, if you only consider your current configuration structure. Do you think the min-version parameter is still useful now?

Also, what happens when the code is written like this?

(defun require-package (package &optional min-version no-refresh)
  "Install given PACKAGE, optionally requiring MIN-VERSION.
If NO-REFRESH is non-nil, the available package lists will not be
re-downloaded in order to locate PACKAGE."
  (if (package-installed-p package min-version)
      t
    (if (or (assoc package package-archive-contents) no-refresh)
        (package-install package nil)
      (progn
        (package-refresh-contents)
        (require-package package min-version t)))))
@purcell

This comment has been minimized.

Copy link
Owner

purcell commented Aug 28, 2018

The issue is that calling package-install only correctly updates package-selected-packages if custom-file has already been loaded. In this config, custom-file is loaded late in the startup process, which makes sense because setting custom vars can cause code to be called, and that code must first have been installed! However, package-selected-packages is stored in custom-file, so there's a deadlock situation with no easy resolution.

@yurimx

This comment has been minimized.

Copy link
Contributor Author

yurimx commented Aug 28, 2018

This is indeed a wrong design...

Why can't I write custom-file first? I think this is the problem.

@purcell

This comment has been minimized.

Copy link
Owner

purcell commented Aug 28, 2018

I think I even filed an emacs bug about it at some point, but I can't remember now.

@yurimx

This comment has been minimized.

Copy link
Contributor Author

yurimx commented Aug 28, 2018

I have submitted at least 4 times. But it is that there is no news or it has been rejected by some tough ones.

In addition, I really don't understand the meaning of your lines of code. Would you like to explain it?

(if (boundp 'package-selected-packages)
;; Record this as a package the user installed explicitly
(package-install package nil)
(package-install package))

purcell added a commit that referenced this issue Aug 28, 2018

@purcell

This comment has been minimized.

Copy link
Owner

purcell commented Aug 28, 2018

I've committed a workaround in 34dfdd3, but I'm not particularly happy about it.

@yurimx

This comment has been minimized.

Copy link
Contributor Author

yurimx commented Aug 28, 2018

Indeed... the cost of this workaround is a bit big...

Maybe we can only continue to feed back this bug upstream and look forward to solving it...

I will close this issue first...

@yurimx yurimx closed this Aug 28, 2018

@yurimx

This comment has been minimized.

Copy link
Contributor Author

yurimx commented Aug 29, 2018

Update:

I looked at some other configuration (like doom-emacs, prelude or spacemacs) to handle this problem...

They all gave up.

svenyurgensson added a commit to svenyurgensson/emacs.d that referenced this issue Oct 3, 2018

cdadar pushed a commit to cdadar/emacs.d that referenced this issue Oct 17, 2018

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