LinuxmacOSWindows

Where Is the Emacs Init File?

Where Emacs looks for init.el across .emacs.d, legacy dotfiles and XDG paths, and which one wins.

Last updated

Emacs configuration centers on ~/.emacs.d: init.el inside it is the modern entry point, with early-init.el running before it for frame and package setup. Legacy ~/.emacs still works and wins nothing: any .emacs.d/init.el takes precedence when both exist.

Emacs 27+ also honors ~/.config/emacs/init.el for XDG users, checked after the classic locations. Packages, auto-save files and custom.el scatter under .emacs.d by default, so the directory (not a single file) is the thing to back up. One folder copy migrates decades of tweaks.

Where Emacs stores this, by platform

Linux
~/.emacs.d/init.el

Respects $XDG_CONFIG_HOME (falls back to ~/.config/emacs). Confirm the live file with C-h v user-init-file. Back up the whole .emacs.d directory, not just init.el.

macOS
~/.emacs.d/init.el

Same lookup order as Linux. Homebrew and MacPorts builds change nothing about placement. GUI and terminal Emacs share the file.

Windows
%APPDATA%\.emacs.d\init.el

Emacs sets HOME to AppData on Windows, so this is where ~/.emacs.d resolves. Confirm with C-h v user-emacs-directory. Same init.el precedence rules apply.

Frequently asked questions

I have several init files. Which one loads?

~/.emacs.d/init.el wins. Emacs checks .emacs, .emacs.el and .emacs.d/init.el in order and loads the first found, ignoring the rest. If your edits seem ignored, you are editing a file that loses the lookup. Confirm with C-h v user-init-file inside Emacs.

How do I move where packages install?

Add (setq package-user-dir ...) or set directories explicitly in early-init.el, which loads before package setup. Default package installs land in ~/.emacs.d/elpa. Version controlled configs usually pin this to keep machines identical.

Notice an outdated path? Let us know.