GNU bug report logs - #15776
On Mac OS X 10.9 Mavericks, Cocoa Emacs starts in the root directory instead of the home directory

Previous Next

Package: emacs;

Reported by: Fazal Majid <majid <at> apsalar.com>

Date: Fri, 1 Nov 2013 06:25:01 UTC

Severity: normal

Merged with 15607

Done: Jan Djärv <jan.h.d <at> swipnet.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Fazal Majid <majid <at> apsalar.com>
To: 15776 <at> debbugs.gnu.org
Subject: bug#15776: On Mac OS X 10.9 Mavericks, Cocoa Emacs starts in the root directory instead of the home directory
Date: Thu, 31 Oct 2013 23:04:46 -0700
I have a build of GNU Emacs for the Mac. On 10.8 Mountain Lion, launching the app works normally - the working directory is my home directory. On 10.9 Mavericks. when launched from the Dock or Finder, the default directory is the root directory instead of my home directory. If launched from the command-line, the correct behavior holds.

It looks like there is custom code in src/emacs.c #ifdef-ed for HAVE_NS and NS_IMPL_COCOA that checks to see if the first or second command-line argument starts with “-psn”, and if so, perform a chdir(getenv(“HOME”)).

It seems like the behavior changes in Mavericks, and apps no longer get the -psn command-line argument. Apps are always launched with a cwd of /, even in Mountain Lion, but now Emacs is not taking corrective action.

The solution is probably to do a version check of OS X and if 10.9 or above, do the chdir anyway.

Here is the patch I am using, which is cruder, as it does not check for OS X version:

--- emacs-24.3/src/emacs.c.dist	2013-10-31 22:36:23.000000000 -0700
+++ emacs-24.3/src/emacs.c	2013-10-31 23:00:45.000000000 -0700
@@ -1173,6 +1173,9 @@
               chdir (getenv ("HOME"));
             }
         }
+      /* On Mavericks, there is no -psn command-line argument so do this anyway,
+         otherwise the CWD would be the root directory */
+      chdir (getenv ("HOME"));
 #endif  /* COCOA */
     }
 #endif /* HAVE_NS */


— Fazal Majid

In GNU Emacs 24.3.1 (x86_64-apple-darwin13.0.0, NS apple-appkit-1265.00)
 of 2013-10-31 on undr.majid.org
Windowing system distributor `Apple', version 10.3.1265
Configured using:
 `configure '--prefix' '/usr/local' '--with-ns' '--with-gif=no'
 '--x-includes=/usr/X11R6/include' '--x-libraries=/usr/X11R6/lib'
 '--with-xpm' 'CC=clang''

Important settings:
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Fundamental

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

Recent input:
C-x C-f C-g M-x r e p <tab> o <tab> r <tab> <retur
n>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit
Making completion list... [2 times]

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr warnings emacsbug message format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils help-mode server disp-table ps-print
ps-def lpr vc vc-dispatcher python rx comint ring ansi-color cc-mode
cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs time-date tooltip ediff-hook vc-hooks lisp-float-type
mwheel ns-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
make-network-process ns multi-tty emacs)

--
Fazal Majid
CTO, Apsalar Inc.
majid <at> apsalar.com
+1 415 347-1277 (347-1APP)





This bug report was last modified 11 years and 201 days ago.

Previous Next


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