diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-03 19:10:44 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-03 19:10:44 -0500 |
| commit | 9acaf3899aedb69300a29a0d0c8b468e5f4ad729 (patch) | |
| tree | e6b4371107685f0a7225876b882145fbc363347d /early-init.el | |
| parent | 475d6305e150c0a8ac61738eabe434c432acd991 (diff) | |
| download | dotemacs-9acaf3899aedb69300a29a0d0c8b468e5f4ad729.tar.gz dotemacs-9acaf3899aedb69300a29a0d0c8b468e5f4ad729.zip | |
fix: expand local ELPA mirror paths with expand-file-name
`(concat user-home-dir ".elpa-mirrors/")` was producing `/home/cjennings.elpa-mirrors/` because `getenv HOME` doesn't return a trailing slash on Linux. The local mirrors were silently dropping out of `package-archives` because `file-accessible-directory-p` couldn't find the bogus path.
I replaced the `concat` calls for `elpa-mirror-location` and `localrepo-location` with `expand-file-name`, which handles the slash for us. I also lifted the four per-archive subdirs into their own constants (`elpa-mirror-gnu-location`, `nongnu`, `melpa`, `stable-melpa`) so the archive registration block stops splicing `concat` strings inline.
I added `tests/test-early-init-paths.el`. It loads `early-init.el` against a temp HOME with the package side effects stubbed and asserts each constant and each `package-archives` entry resolves to the right path.
Diffstat (limited to 'early-init.el')
| -rw-r--r-- | early-init.el | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/early-init.el b/early-init.el index 9f90f292..49a9da92 100644 --- a/early-init.el +++ b/early-init.el @@ -116,14 +116,32 @@ Set to nil to use only local repos.") (defconst user-home-dir (getenv "HOME") "The user's home directory per the environment variable.") -(defconst elpa-mirror-location (concat user-home-dir ".elpa-mirrors/") +(defconst elpa-mirror-location + (expand-file-name ".elpa-mirrors/" user-home-dir) "The path to the elpa mirror location.") -(defconst localrepo-location (concat user-emacs-directory ".localrepo/") +(defconst localrepo-location + (expand-file-name ".localrepo/" user-emacs-directory) "The path to your local Emacs package repository. For more information about the local Emacs package repository, see comments in early-init.el.") +(defconst elpa-mirror-gnu-location + (expand-file-name "gnu/" elpa-mirror-location) + "The path to the local GNU ELPA mirror.") + +(defconst elpa-mirror-nongnu-location + (expand-file-name "nongnu/" elpa-mirror-location) + "The path to the local NonGNU ELPA mirror.") + +(defconst elpa-mirror-melpa-location + (expand-file-name "melpa/" elpa-mirror-location) + "The path to the local MELPA mirror.") + +(defconst elpa-mirror-stable-melpa-location + (expand-file-name "stable-melpa/" elpa-mirror-location) + "The path to the local MELPA Stable mirror.") + (setq package-archives nil) ;; package-archives will be added below ;; LOCAL REPOSITORY (packages in version control) @@ -132,20 +150,20 @@ early-init.el.") (add-to-list 'package-archive-priorities '("localrepo" . 200))) ;; LOCAL REPOSITORY ELPA MIRRORS -(when (file-accessible-directory-p (concat elpa-mirror-location "gnu")) - (add-to-list 'package-archives (cons "gnu-local" (concat elpa-mirror-location "gnu/")) t) +(when (file-accessible-directory-p elpa-mirror-gnu-location) + (add-to-list 'package-archives (cons "gnu-local" elpa-mirror-gnu-location) t) (add-to-list 'package-archive-priorities '("gnu-local" . 125))) -(when (file-accessible-directory-p (concat elpa-mirror-location "nongnu")) - (add-to-list 'package-archives (cons "nongnu-local" (concat elpa-mirror-location "nongnu/")) t) +(when (file-accessible-directory-p elpa-mirror-nongnu-location) + (add-to-list 'package-archives (cons "nongnu-local" elpa-mirror-nongnu-location) t) (add-to-list 'package-archive-priorities '("nongnu-local" . 120))) -(when (file-accessible-directory-p (concat elpa-mirror-location "melpa")) - (add-to-list 'package-archives (cons "melpa-local" (concat elpa-mirror-location "melpa/")) t) +(when (file-accessible-directory-p elpa-mirror-melpa-location) + (add-to-list 'package-archives (cons "melpa-local" elpa-mirror-melpa-location) t) (add-to-list 'package-archive-priorities '("melpa-local" . 115))) -(when (file-accessible-directory-p (concat elpa-mirror-location "stable-melpa")) - (add-to-list 'package-archives (cons "melpa-stable-local" (concat elpa-mirror-location "stable-melpa/")) t) +(when (file-accessible-directory-p elpa-mirror-stable-melpa-location) + (add-to-list 'package-archives (cons "melpa-stable-local" elpa-mirror-stable-melpa-location) t) (add-to-list 'package-archive-priorities '("melpa-stable-local" . 100))) ;; ONLINE REPOSITORIES |
