plexus / chemacs2

Emacs version switcher, improved
779 stars 47 forks source link

package-user-dir stays at ~/.emacs.d/elpa #16

Closed kidd closed 3 years ago

kidd commented 3 years ago

Recently there's been a change in emacs master branch, 9973019764250ac1f4d77a6b426cdd9c241151c5 ( https://github.com/emacs-mirror/emacs/commit/9973019764250ac1f4d77a6b426cdd9c241151c5) where package-user-dir is loaded differently, making it bypass chemacs' directory linking.

c-h v package-user-dir before that commit gives ~/.emacs.default/elpa, but after it, you get ~/.emacs.d/elpa.

I'm still not 100% sure about the proper fix, but as of now this seems to fix it:

modified   chemacs.el
@@ -142,6 +142,7 @@
 (defun chemacs-load-user-init ()
   (when (chemacs-profile-get 'straight-p) (chemacs-load-straight))
   (let ((init-file (expand-file-name "init.el" user-emacs-directory)))
+    (setq package-user-dir (expand-file-name "elpa" user-emacs-directory))
     (load init-file t t)
     ;; Prevent customize from changing ~/.emacs (this file), but if
     ;; init.el has set a value for custom-file then don't touch it.

leaving it as an issue to give it some time

plexus commented 3 years ago

Thanks for the report. If this works both before and after that change then I'm happy to merge in a PR.

patrolli commented 3 years ago

Recently there's been a change in emacs master branch, 9973019764250ac1f4d77a6b426cdd9c241151c5 ( emacs-mirror/emacs@9973019) where package-user-dir is loaded differently, making it bypass chemacs' directory linking.

c-h v package-user-dir before that commit gives ~/.emacs.default/elpa, but after it, you get ~/.emacs.d/elpa.

I'm still not 100% sure about the proper fix, but as of now this seems to fix it:

modified   chemacs.el
@@ -142,6 +142,7 @@
 (defun chemacs-load-user-init ()
   (when (chemacs-profile-get 'straight-p) (chemacs-load-straight))
   (let ((init-file (expand-file-name "init.el" user-emacs-directory)))
+    (setq package-user-dir (expand-file-name "elpa" user-emacs-directory))
     (load init-file t t)
     ;; Prevent customize from changing ~/.emacs (this file), but if
     ;; init.el has set a value for custom-file then don't touch it.

leaving it as an issue to give it some time

It works. I recently compile emacs28 to replace my old emacs27. I found when I enter emacs28 it will download packages automatically to the path "~/.emacs.d" instead of loading from "~/.emacs.default". I add this sentence in chemacs.el and emacs28 load the package dir correctly.

plexus commented 3 years ago

@patrolli did you also try it out with the change on emacs 27?

@kidd or @patrolli would you mind making a PR for this?

kidd commented 3 years ago

sure! I'll prepare the PR later today, :+1: