My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Rescue your `.spacemacs` from managed packages

Heechul Ryu's photo
Heechul Ryu
·Apr 7, 2020

Stop checking custom-set-variables or package-selected-packages in your git. (like I did it for years...)

Are you a Spacemacs user and manage your dotspacemacs file on git? Then you might have wondered if you could not worry about a long list of package names in your dotfile.

Whenever a package is installed, the newly installed packages are listed under package-selected-packages on the bottom of your .spacemacs.

I've switched my main editor to (Space)Vim for a while. But still yesterday I played with Spacemacs again and that activity let the dot file to be updated.

And it really bugged me that package-selected-packages got updated by Spacemacs breaking my vertical alignment of the list (plus the list got quite long now).

;; visualizing my pain

;; this
(custom-set-variables
  ;; ...
 '(package-selected-packages
   (quote
    (org
     flyspell-correct-helm
     flyspell-correct
     auto-dictionary
     indium
     ghub
     ;; ...
    )))

;; becomes this
  ;; ...
 '(package-selected-packages
   (quote
    (org flyspell-correct-helm new-package flyspell-correct auto-dictionary indium ghub ...)))

I've decided to find a solution

instead of dirtying git history continuously or letting the part unstaged all the time

So I googled and found out that the package list is not necessary to be tracked in a git.

And after reading this comment and the code in the link of the comment, I got confident that I can do the following:

(defun dotspacemacs/user-init ()
  ;; ...
  (setq custom-file "~/.emacs.d/.cache/custom-file.cache")
  ;; ...

you can use any path and filename I just chose ~/.emacs.d/.cache/custom-file.cache because that make sense to me

And delete the whole section of custom-set-variables in .spacemacs

Later you will see that section will appear into ~/.emacs.d/.cache/custom-file.cache file (when emacs performs an updating package list) which you don't need to track with your git.

😁 Now I don't need to worry about package-selected-packages ever again (hopefully).