Subject: bug#42836: 27.1; default-directory is set to "/" after startup

From: Sean Devlin <[email-masked]>
Date: Wed, 12 Aug 2020 16:53:56 -0400

Hi folks,

When I start Emacs, the value of default-directory in the *scratch* and
*Messages* buffers is "/". In previous versions of Emacs, it was "~/".

I am on macOS, and I installed Emacs 27.1 as packaged by
https://emacsformacosx.com. There is information about how this is built
and packaged here: https://emacsformacosx.com/about.

Basically, it provides a .app bundle as per typical on macOS. This lets
you open Emacs by clicking on the application icon or running "open -a
Emacs" from the terminal. You can also run it directly by invoking the
full path to the executable
(e.g. /Applications/Emacs.app/Contents/MacOS/Emacs) from the terminal.

When I open Emacs 27.1 by either of the first two methods, the value of
default-directory in the *scratch* and *Messages* buffers is "/". This
is true even though the process working directory is my home directory,
which I verified by running "lsof -a -d cwd -p $(pgrep -i emacs)" after
starting Emacs.

I reinstalled a copy of Emacs 26.3 and verified default-directory used
to be "~/" in these buffers after startup.

When I open Emacs 27.1 by invoking the executable directly (i.e. the
last method above), the default-directory in those buffers is "~/".

I have performed all the above steps using the "-Q" argument to make
sure my own configuration is not confounding anything.

I think you should be able to reproduce by the following steps:

1. Download Emacs from https://emacsformacosx.com and install the
application. (I think
https://emacsformacosx.com/emacs-builds/Emacs-27.1-universal.dmg is the
right URL.)
2. In a terminal, run "open -a Emacs --args -Q" to start Emacs.
3. Once Emacs starts, switch to the *scratch* buffer and evaluate
"default-directory" or "(pwd)" and observe the result.

I tried to do a little digging to determine how and when this variable
is first set to "/", but I couldn't figure it out. It seems that the
default directory is already "/" by the time early-init.el runs. I
determined this by putting "(message default-directory)" in my
early-init.el file and checking the messages buffer after startup.

Please let me know if there's any more information I can provide.

Thanks!

In GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2020-08-12 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.2004
System Description:  macOS

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
Mark deactivated
Making completion list...

Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES
THREADS JSON PDUMPER

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core term/tty-colors frame
minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite charscript charprop case-table epa-hook jka-cmpr-hook help
simple abbrev obarray cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
threads kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 44955 6142)
(symbols 48 5927 1)
(strings 32 15262 1819)
(string-bytes 1 504806)
(vectors 16 10186)
(vector-slots 8 126975 12482)
(floats 8 19 42)
(intervals 56 201 0)
(buffers 1000 12))