I just installed GNU Emacs 23.1.1 on a new machine and copied my ~/.emacs and ~/.emacs.d/ from another machine where I'm running emacs 25.1.1.

When I launch emacs it writes Error (initialization): User <my_id> has no home directory into a buffer. Not surprisingly, it also has not read .emacs.

One thing odd about this machine is that home directories are stored in /home/, rather than in /mxhome/ like in the rest of my work environment, and this new machine has a symlink from /mxhome -> /home. I don't know if that is important.

UPDATE: launching with emacs -q -l /home/my_id/.emacs filename loads the .emacs file and avoids the error, although I don't know if it solves the problem entirely.

Emacs administration is largely a mystery to me. Can anyone help?

  • Do you still see the problem with emacs --no-site-file?
    – Stefan
    Jul 7, 2017 at 23:27
  • Do you have a HOME environment variable set? If not, try setting HOME.
    – Drew
    Jul 7, 2017 at 23:54
  • @Stefan @Drew I still see the problem with emacs --no-site-file. I do have HOME set to /mxhome/my_id which, as noted above, is a symlink.
    – Chap
    Jul 8, 2017 at 0:05

4 Answers 4


Following the idea from @glucas, I debugged the variable init-file-user, and came up with a temporary solution

alias emacs='emacs --user ""'

With --user '', it enforced the init-file-user to be an empty string, then

(file-directory-p (expand-file-name (concat "~" init-file-user)))

would be properly evaluated to the correct path.

My case is really odd, and I've tried emacs-25.2, 25.3 and 26.1. They all produce the same problem. However, this problem only appears on CentOS7, but not CentOS6. So, I compared the difference in the value of init-file-user between the two systems, and came up with the above solution. On CentOS6, init-file-user is an empty string, emacs works; but on CentOS7, it's , producing error.

I still don't know how the value of init-file-user is initialized, the source code for startup.el is rather overwhelming.

  • 2
    Over a year later and I'm just getting back to this. Using --user "" solves my problem, or at least works around it as you described.
    – Chap
    Nov 6, 2018 at 23:03
  • This worked for me too in Amazon Linux . Really weird
    – MikeHoss
    Jul 5, 2022 at 14:33

I would try starting emacs with HOME set to /home/my_id (rather than the symlink), since explicitly using that path seems to work.

The error message ("user has no home directory") is coming from startup.el. You may be able to use --debug-init to investigate further.

Basically the error message implies the following is false:

(file-directory-p (expand-file-name (concat "~" init-file-user)))

You could try starting Emacs with your workaround and evaluate (expand-file-name "~") and (file-directory-p (expand-file-name "~")) and see if they are returning what you'd expect.

  • 1
    env HOME=/home/my_id emacs still throws the error. Then evaluating (expand-file-name "~") gives /mxhome/my_id, oddly. And, evaluating (file-directory-p (expand-file-name (concat "~" init-file-user))) is indeed nil. I will try using --debug-init.
    – Chap
    Jul 8, 2017 at 1:55
  • Does (expand-file-name (concat "~" init-file-user)) give you /home/my_id/~my_id or something like that. That's what I see with the same error message. I don't have fix yet
    – zyxue
    Aug 25, 2017 at 15:58
  • @zyxue it gives "/home/my_id"
    – Chap
    Mar 27, 2018 at 15:19
  • Also, I found that init-file-user is nil
    – Chap
    Mar 27, 2018 at 15:25

The root cause of not resolving ~user properly was fixed for me by installing nscd.


Change your home path. If your computer's OS is Windows.You can check the regedit. The path is: HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs\Home Change it to your Emacs location.

  • It is much easier to set the environment variable HOME in this case.
    – theldoria
    Aug 12, 2017 at 6:27

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.