unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#47298: Emacs creates HOME if it does not exist
@ 2021-03-21 17:40 Glenn Morris
  2021-03-21 19:03 ` Andreas Schwab
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Glenn Morris @ 2021-03-21 17:40 UTC (permalink / raw)
  To: 47298; +Cc: eggert

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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#47298: Emacs creates HOME if it does not exist
  2021-03-21 17:40 bug#47298: Emacs creates HOME if it does not exist Glenn Morris
@ 2021-03-21 19:03 ` Andreas Schwab
  2021-03-22  6:55 ` Jean Louis
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2021-03-21 19:03 UTC (permalink / raw)
  To: Glenn Morris; +Cc: eggert, 47298

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@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#47298: Emacs creates HOME if it does not exist
  2021-03-21 17:40 bug#47298: Emacs creates HOME if it does not exist Glenn Morris
  2021-03-21 19:03 ` Andreas Schwab
@ 2021-03-22  6:55 ` Jean Louis
  2021-03-22 17:29 ` Eli Zaretskii
  2022-06-25 15:28 ` Lars Ingebrigtsen
  3 siblings, 0 replies; 7+ messages in thread
From: Jean Louis @ 2021-03-22  6:55 UTC (permalink / raw)
  To: Glenn Morris; +Cc: eggert, 47298

* Glenn Morris <rgm@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?







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#47298: Emacs creates HOME if it does not exist
  2021-03-21 17:40 bug#47298: Emacs creates HOME if it does not exist Glenn Morris
  2021-03-21 19:03 ` Andreas Schwab
  2021-03-22  6:55 ` Jean Louis
@ 2021-03-22 17:29 ` Eli Zaretskii
  2021-03-25 18:28   ` Glenn Morris
  2022-06-25 15:28 ` Lars Ingebrigtsen
  3 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2021-03-22 17:29 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 47298

> From: Glenn Morris <rgm@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?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#47298: Emacs creates HOME if it does not exist
  2021-03-22 17:29 ` Eli Zaretskii
@ 2021-03-25 18:28   ` Glenn Morris
  2021-03-26  9:18     ` Jean Louis
  0 siblings, 1 reply; 7+ messages in thread
From: Glenn Morris @ 2021-03-25 18:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47298

Eli Zaretskii wrote:

>> From: Glenn Morris <rgm@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#47298: Emacs creates HOME if it does not exist
  2021-03-25 18:28   ` Glenn Morris
@ 2021-03-26  9:18     ` Jean Louis
  0 siblings, 0 replies; 7+ messages in thread
From: Jean Louis @ 2021-03-26  9:18 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 47298

* Glenn Morris <rgm@gnu.org> [2021-03-25 21:29]:
> Eli Zaretskii wrote:
> 
> >> From: Glenn Morris <rgm@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#47298: Emacs creates HOME if it does not exist
  2021-03-21 17:40 bug#47298: Emacs creates HOME if it does not exist Glenn Morris
                   ` (2 preceding siblings ...)
  2021-03-22 17:29 ` Eli Zaretskii
@ 2022-06-25 15:28 ` Lars Ingebrigtsen
  3 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-25 15:28 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 47298

Glenn Morris <rgm@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-25 15:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21 17:40 bug#47298: Emacs creates HOME if it does not exist Glenn Morris
2021-03-21 19:03 ` Andreas Schwab
2021-03-22  6:55 ` Jean Louis
2021-03-22 17:29 ` Eli Zaretskii
2021-03-25 18:28   ` Glenn Morris
2021-03-26  9:18     ` Jean Louis
2022-06-25 15:28 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).