purcell / exec-path-from-shell

Make Emacs use the $PATH set up by the user's shell
Other
1.43k stars 82 forks source link

exec-path-from-shell invokes new 'login', spawns new dwm / xorg sessions #93

Closed comalice closed 5 years ago

comalice commented 5 years ago

new sessions of dwm launches when emacs is started

As the headline above states, when I start emacs (with spacemacs installed) I get two new sessions of dwm, one right after another. They appear to be blocking, because emacs won't continue to load until I exit out of each session.

configurations

.profile

startx

.xinitrc

exec dwm

.xsession-bak (moved for debugging, not currently in use)

#!/bin/sh

#
# ~/.xsession
#
# Executed by xdm/gdm/kdm at login
#

/bin/sh -l ~/.xinitrc

emacs / xorg output on startup

Error (use-package): exec-path-from-shell/:init: Expected printf from shell, but got "/bin/ash: can't access ttyp: job control turned off

...Xorg starts up here...

I think the issue arises here: https://github.com/purcell/exec-path-from-shell/blob/3cfedb8791397ed50ee66bc0a7cbee5b9d78245c/exec-path-from-shell.el#L121-L132, because when I also call /bin/ash/ -l the behaviour is the same; I get a new session of dwm/Xorg opened up.

It appears that sh parses .profile when -l is used (a POSIX standard per here: https://linux.die.net/man/1/sh) and when .profile is called, I get a new session of dwm.

Solution

https://bbs.archlinux.org/viewtopic.php?id=144119

Change .profile to something like this:

if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
    startx
fi
comalice commented 5 years ago

I found a solution mid-stride. I'm putting this here in case someone else also wastes themselves against this issue for two days straight.

purcell commented 5 years ago

Yes, see also https://github.com/purcell/exec-path-from-shell/issues/89.