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].

What could -u [my-user] load that is not in my ~/.emacs.d/init.el?

I had a look at The Emacs Initialization File and How Emacs Finds Your Init File. It lists several other possibilities for init files. None seems present on my system.

Specifically, none of these files exist:

  • ~/.emacs.el
  • ~/.emacs
  • ~/.config/emacs/

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:

  1. 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.


1 Answer 1


The weird thing is that -Q -u [user] loads an init file at all. I'd call that a bug, but it's probably been this way for decades.

Given that it does, I suspect there's no difference between these:

  • emacs
  • emacs -q -u "$USER"

I.e. you've reverted the --no-init-file (aka -q) behaviour by specifying an init file (although again, I find that surprising).

If that's correct, then the only difference to emacs -Q -u "$USER" would be the difference between -q and -Q. As you can see from emacs --help:

--quick, -Q                 equivalent to:
                              -q --no-site-file --no-site-lisp --no-splash

Conversely emacs -Q -l [my-init-file] isn't overriding --no-init-file and so you can expect the behaviour you've quoted from the documentation to hold.

Note also that -l isn't processed until later in the start-up sequence, and so even if the options you passed didn't have additional effects, loading a file with -l would not necessarily give the same outcome as Emacs loading it as an init file.

  • What I still don't understand is why I get the error regarding package-archives being void when I start with -Q -l. I understand that it is because package.el is not initialized, but then what does initialize it when I run with -Q -u? I don't initialize it at all in my init.el.
    – Victor
    Commented Apr 20, 2021 at 11:42
  • Emacs does it for you. You quoted it yourself -- Emacs calls package-activate-all when there's an init file. Those docs don't account for this (somewhat unusual) scenario, but by adding -u you've caused there to be an init file despite using -Q, and so packages are initialized.
    – phils
    Commented Apr 20, 2021 at 12:01
  • For clarity, by "when there's an init file" I mean "the --no-init-file option is not in effect". The init file itself doesn't need to exist. The -u option is evidentially preventing --no-init-file from being set, despite -Q being passed.
    – phils
    Commented Apr 20, 2021 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.