GNU bug report logs - #47298
Emacs creates HOME if it does not exist

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Sun, 21 Mar 2021 17:42:02 UTC

Severity: minor

Found in version 27.1

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47298 in the body.
You can then email your comments to 47298 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to eggert <at> cs.ucla.edu, bug-gnu-emacs <at> gnu.org:
bug#47298; Package emacs. (Sun, 21 Mar 2021 17:42:02 GMT) Full text and rfc822 format available.

Message #3 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: Emacs creates HOME if it does not exist
Date: Sun, 21 Mar 2021 13:40:53 -0400
Package: emacs
Version: 27.1
Severity: minor

Assuming /tmp/foo does not exist:

HOME=/tmp/foo emacs-26.3

Emacs starts, but displays a warning:
  
  Warning (initialization): Unable to create `user-emacs-directory' (~/.emacs.d/).
  Any data that would normally be written there may be lost!
  If you never want to see this message again,
  customize the variable `user-emacs-directory-warning'.
  Error (initialization): User someuser has no home directory


With Emacs 27.1, HOME is silently created.
(Only interactively; this does not happen in batch mode.)

I assume a4144af909, which added the PARENTS argument to the
make-directory call in locate-user-emacs-file, causes this.

IMO the Emacs 26.3 behaviour is correct, and Emacs should not be
creating HOME if it does not exist. One may want to set a non-existent
HOME eg for testing.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47298; Package emacs. (Sun, 21 Mar 2021 19:04:02 GMT) Full text and rfc822 format available.

Message #6 received at 47298 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: eggert <at> cs.ucla.edu, 47298 <at> debbugs.gnu.org
Subject: Re: bug#47298: Emacs creates HOME if it does not exist
Date: Sun, 21 Mar 2021 20:03:12 +0100
On Mär 21 2021, Glenn Morris wrote:

> One may want to set a non-existent HOME eg for testing.

It is probably better to use an existing, but write-protected directory.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47298; Package emacs. (Mon, 22 Mar 2021 06:59:01 GMT) Full text and rfc822 format available.

Message #9 received at 47298 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Glenn Morris <rgm <at> gnu.org>
Cc: eggert <at> cs.ucla.edu, 47298 <at> debbugs.gnu.org
Subject: Re: bug#47298: Emacs creates HOME if it does not exist
Date: Mon, 22 Mar 2021 09:55:45 +0300
* Glenn Morris <rgm <at> gnu.org> [2021-03-21 20:42]:
> IMO the Emacs 26.3 behaviour is correct, and Emacs should not be
> creating HOME if it does not exist. One may want to set a non-existent
> HOME eg for testing.

Warning is better as it gives control to user. Yet in regards to
testing with non-existent Emacs directory .emacs.d do you think would
there be some difference if an empty directory is created by Emacs
compared to no directory at all?






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47298; Package emacs. (Mon, 22 Mar 2021 17:30:02 GMT) Full text and rfc822 format available.

Message #12 received at 47298 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 47298 <at> debbugs.gnu.org
Subject: Re: bug#47298: Emacs creates HOME if it does not exist
Date: Mon, 22 Mar 2021 19:29:23 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Date: Sun, 21 Mar 2021 13:40:53 -0400
> 
> IMO the Emacs 26.3 behaviour is correct, and Emacs should not be
> creating HOME if it does not exist.

I'm not sure I agree with you.  What do other programs do in this
situation?  And if we don't create ~/.emacs.d, how can we save user's
customizations?

> One may want to set a non-existent HOME eg for testing.

That might mean we need to find other ways of isolating tests from
user customizations.

Does anyone else have an opinion on this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47298; Package emacs. (Thu, 25 Mar 2021 18:29:02 GMT) Full text and rfc822 format available.

Message #15 received at 47298 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 47298 <at> debbugs.gnu.org
Subject: Re: bug#47298: Emacs creates HOME if it does not exist
Date: Thu, 25 Mar 2021 14:28:20 -0400
Eli Zaretskii wrote:

>> From: Glenn Morris <rgm <at> gnu.org>
>> Date: Sun, 21 Mar 2021 13:40:53 -0400
>> 
>> IMO the Emacs 26.3 behaviour is correct, and Emacs should not be
>> creating HOME if it does not exist.
>
> I'm not sure I agree with you.  What do other programs do in this
> situation?

Dunno.
IMO applications should not be creating HOME, that is a system-level
responsibility.
Missing HOME indicates either a deliberate choice, or a system-level
problem that the application should not try to fix (in most cases, it
won't even have permission to do so) but should just report.

> And if we don't create ~/.emacs.d, how can we save user's
> customizations?

You don't, you give a warning.

> That might mean we need to find other ways of isolating tests from
> user customizations.

Your only alternative is to have the test machinery make a temporary but
existing HOME and ensure it is deleted afterwards.
But IMO that is a separate issue.
Even if that change is made, I still don't believe Emacs should create HOME.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47298; Package emacs. (Fri, 26 Mar 2021 09:19:03 GMT) Full text and rfc822 format available.

Message #18 received at 47298 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 47298 <at> debbugs.gnu.org
Subject: Re: bug#47298: Emacs creates HOME if it does not exist
Date: Fri, 26 Mar 2021 12:18:20 +0300
* Glenn Morris <rgm <at> gnu.org> [2021-03-25 21:29]:
> Eli Zaretskii wrote:
> 
> >> From: Glenn Morris <rgm <at> gnu.org>
> >> Date: Sun, 21 Mar 2021 13:40:53 -0400
> >> 
> >> IMO the Emacs 26.3 behaviour is correct, and Emacs should not be
> >> creating HOME if it does not exist.
> >
> > I'm not sure I agree with you.  What do other programs do in this
> > situation?
> 
> Dunno.
> IMO applications should not be creating HOME, that is a system-level
> responsibility.

Emacs also does not create home directly, it creates its own
configuration directory appended to environment variable $HOME --
which in most cases is home directory of a user, but may not be. Home
directory of a user is located in /etc/passwd and $HOME is
customization that users still can do for other purpose.

If Emacs does not touch /etc/passwd or look for user's home there,
then is not creating user's home, it is creating its configuration
directory as appended to environment variable $HOME -- and other
applications do exactly the same!

Plethora of applications are creating their configurations in
~/.config -- so please look there, you will find all created
directories. 

Applications are then probably finding where is the config directory
by deriving it from $HOME environment variable or $XDG_CONFIG_HOME and
when $XDG_CONFIG_HOME is not there it is derived maybe from
XDG_CONFIG_HOME="$HOME/.config"

> Missing HOME indicates either a deliberate choice, or a system-level
> problem that the application should not try to fix (in most cases, it
> won't even have permission to do so) but should just report.

When application like Emacs runs, it does not "create home" as above
explained, but it wants to create its directory for future
functionality. Using $HOME environment variable is not same as user's
home directory, which is defined in /etc/passwd and need not be
defined in $HOME automatically -- though that is what systems do for
convenience.

I can enter in the system at /root point, it does not matter, $HOME is
where I have permission and my files. 

> > And if we don't create ~/.emacs.d, how can we save user's
> > customizations?
> 
> You don't, you give a warning.

Your assumption that Emacs changes or fiddles with user's home is
incorrect. It works (probably, me insecure) with $HOME variable which
is not equal to user's home, which is irrelevant to user's home
directory! 

I don't agree with this quite, as I use Emacs on Lineage OS, Android
OS, there are setups you do not know, and where this statement does
not apply. In fact there is no specific user's directory on such
systems and it depends of the access:

On the same system:

$ adb shell (but I am not root)
condor:/ $ echo $HOME
/

and I have no permissions to write in that directory, obviously it is
not real home, but I have $HOME.

Then different SSH application would give me different $HOME.

$ ssh motorolausb
$ echo $HOME
/data/data/com.termux/files/home

which is inconvenient, so I like changing $HOME variable to
/storage/emulated/0 as that is where Pictures, and Videos are located
as well, makes more sense to me.

> > That might mean we need to find other ways of isolating tests from
> > user customizations.
> 
> Your only alternative is to have the test machinery make a temporary but
> existing HOME and ensure it is deleted afterwards.
> But IMO that is a separate issue.
> Even if that change is made, I still don't believe Emacs should create HOME.

I think it should as all other applications follow that. Creating
$HOME is not same as creating user's home directory as specified in
/etc/passwd -- while similar, those things are not same, I have given
you example from Lineage OS system.

If the configuration directory cannot be created, no warning should be
issued as user is invoking Emacs most probably to edit text and there
is no need to confuse editing with configuration.

When configuration cannot be saved because the directory could not be
created, at the time point of not being able to save configuration,
that is where warning should be issued.

Jean




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47298; Package emacs. (Sat, 25 Jun 2022 15:29:02 GMT) Full text and rfc822 format available.

Message #21 received at 47298 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 47298 <at> debbugs.gnu.org
Subject: Re: bug#47298: Emacs creates HOME if it does not exist
Date: Sat, 25 Jun 2022 17:28:37 +0200
Glenn Morris <rgm <at> gnu.org> writes:

> IMO the Emacs 26.3 behaviour is correct, and Emacs should not be
> creating HOME if it does not exist. One may want to set a non-existent
> HOME eg for testing.

I've now fixed this in Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 47298 <at> debbugs.gnu.org and Glenn Morris <rgm <at> gnu.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 25 Jun 2022 15:29:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 24 Jul 2022 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 333 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.