I am trying to understand the subtle nuances of Emacs' packaging system(s). I do not find that anyone has really clarified or explained the difference between two, what I assume to be, key components of Emacs package system:
I commonly see code like the following in many
init.el files (illustrative example):
(require 'package) ; Use Emacs package system (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) ; Add MELPA package repository as a place to go lookup for packages (package-initialize) ; Turns Emacs package system on ; ... refresh code omitted for brevity (unless (package-installed-p 'helm) ; Only installed "helm" if we don't see it as already installed (package-install 'helm) ) (require 'helm) ; Get helm to actually use ; ...
The thought process for understanding what is going on:
requireseems to be called for
packagebut the "package" for
packagedoes not need to be "installed". Is this internal somehow?
use-packageto work but not
helm(in this example) we must do/use
package-install(with some checks) to first "install"
requireto actually use it. Is this correct?
- If we did
(use-package helm ... )then we would not need either
package-install 'helm, right?
If one wanted to use any particular package, they first need to make sure they have an equivalent
package-install call / statement prior to invoking
require (or just utilize a
use-package which will "merge" both steps) on that particular package, correct?
I just want to be sure I am properly setting up my usage of packages and so forth. Emacs is very confusing when it comes to packages, installing, requiring, etc. ... at least that I find.
Q/A Housekeeping Notes:
According to common advice, there are important differences in the Emacs major versions, so I would like an explanation for each (Emacs version 25, 26, and 27, respectively) for others who may come across the same question but on an older version (if it matters).
I am currently on Emacs 27.2 on macOS Catalina (just to be clear).
In an attempt to preempt "duplicate of ..." or "searching will find ...": In my searching, I found require vs. package-initialize? but it does not look like anyone really answered the question to satisfaction (or clearly).
package-install. It covered another command. I am not sure what is exactly overwhelming about my question here. "What is the difference between
package-install?". I outlined my thoughts as I was trying to understand it.