Subject: bug#25819: 25.1; Added by Package.el. Added by Package.el. Added by Package.el. Added by Package.el.

From: [email-masked]
Date: Wed, 22 Feb 2017 12:48:53 -0800

On Wed, Feb 22, 2017 at 02:28:27PM -0500, Glenn Morris wrote:
> [email-masked] wrote:
> 
> > root) My /root/.emacs looks something like this:
> >
> >     (setenv "HOME" "/home/frederik/")
> >     (setq savehist-file "/root/.emacs-history")
> >     (load "~/.emacs")
> >     (setenv "HOME" "/root/")
> >
> > Obviously this does not contain a "(package-initialize)" line, so the
> [...]
> > I wasn't able to figure out why the "(package-initialize)" lines then
> > get inserted in ~/.emacs rather than /root/.emacs, but I hope the
> > above clues provide a good enough place for someone else to start
> > debugging this.
> 
> I tested with:
> 
> /tmp/h1/.emacs:
>     (setenv "HOME" "/tmp/h2/")
>     (setq savehist-file "/tmp/h1/.emacs-history")
>     (load "~/.emacs")
>     (setenv "HOME" "/tmp/h1/")
> 
> /tmp/h2/.emacs:
>     (setq foo 99)
> 
> 
> HOME=/tmp/h1 emacs-25.1
> M-x package-initialize
> 
> and could not reproduce any problem.
> The package lines get added to /tmp/h1/.emacs, once only.
> 
> If you don't feel like debugging further, you could just add a
> commented out package-initialize line to /root/.emacs.
> Somehow I don't think your problem is a common one. :)

You don't think my problem is common!? :) Well I'm not sure how other
people edit files as root, but after a few incarnations I decided that
a barebones /root/.emacs pointing to ~/.emacs is the best way to go.

Thank you (indeed) for taking the time to trim down my problem to a
minimal test case. If we make it a little less minimal:

/tmp/h2/.emacs:
    (setq foo 99)
    (package-initialize)

then I find it reproduces the problem:

/tmp/h2/.emacs:
    ;; Added by Package.el.  This must come before configurations of
    ;; installed packages.  Don't delete this line.  If you don't want it,
    ;; just comment it out by adding a semicolon to the start of the line.
    ;; You may delete these explanatory comments.
    (package-initialize)

    (setq foo 99)
    (package-initialize)

Thanks,

Frederick