I have all my emacs config in
.emacs.d/init.el. The first command in that file is:
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
When I start emacs with
emacs -Q -u [my-user] it works fine.
But when I start it with
emacs -Q -l ~/.emacs.d/init.el I get the error
Symbol’s value as variable is void: package-archives.
I know that I can add
(require 'package) at the top of init.el to solve this problem. However, I'm trying to understand why I don't get that error with
emacs -Q -u [my-user].
Besides I encounter other similar problems down the line with
-Q -l ~/.emacs.d/init.el which are not present with
-Q -u [my-user].
-u [my-user] load that is not in my
Specifically, none of these files exist:
I don't seem to have a site-wide
default.el. Anyway the docs say that it would be loaded after my
init.el so it would not explain why emacs chokes on the 1st line of that file.
I don't have
site-start.el either. Confirming this, it makes no difference whether I append
--no-site-file to the above commands.
In the Startup Summary I saw this:
- It calls the function package-activate-all to activate any optional Emacs Lisp package that has been installed. See Packaging Basics. However, Emacs doesn’t activate the packages when package-enable-at-startup is nil or when it’s started with one of the options ‘-q’, ‘-Q’, or ‘--batch’.
I still don't understand why it works with
-Q -u [my-user] and not with
-Q -l [my-init-file].
I have GNU Emacs 27.1 built from source on Debian Buster.