Subject: Re: bug#28025: Daemon/server passes string incorrectly to/from Systemd

From: Arthur Miller <[email-masked]>
Date: Thu, 10 Aug 2017 14:42:11 +0200

> Can you explain how DICPATH enters this picture?  AFAIR, Hunspell
> should be able to find its dictionaries without that variable,
> assuming Hunspell is installed correctly.  So why do you need DICPATH?

Above stack trace points to "ispell-parse-hunspell-affix-file", which seems
to
be a parser for affix files. But as I wrote I am not sure, I don't know so
much
about how emacs does stuff internally. Anyway, I have checked so that path
given to emacs is not empty. When I do (getenv "DICPATH") it prints correct
path where dictionaries are. Hunspell is found as well, and Hunspell itself
finds everything correctly when I check from shell.

> I don't see what D-Bus would have to do with this.
Systemd-bus is D-bus if I understood Systemd docs correctly. I am by no
means an expert in either d-bus or sytemd, just ordinary user.

> I imagine that the environment of Emacs when started from systemd is
> different from when you start it normally, and something is missing that
> means hunspell can't find its dictionaries.

Yeah, I imagined that too, so that is why I passed DICPATH to systemd
service as well but that didn't solve the problem. Here is service file. If
Emas gets it's paths from Hunspell, than it sounds as expected, and after
that the only thing I can imagine is problem is how strings are passed
between processes.

I looked at process-environment var and the content is different,
but what regards PATH and DICPATH it's same:

Emacs daemon started with systemd as user service:

("TERM=dumb" "DICPATH=~/.emacs.d/hunspell"
"INVOCATION_ID=af861fc0688846f6a70a09261064560f" "MANAGERPID=604"
"XDG_RUNTIME_DIR=/run/user/1000" "USER=*****" "SHELL=/bin/bash"
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
"MAIL=/var/spool/mail/*****" "LOGNAME=*****" "LANG=sv_SE.UTF-8"
"JOURNAL_STREAM=9:15268" "HOME=/home/*****"
"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus")

Emacs daemon started from shell:

("OLDPWD=/home/*****" "_=/usr/local/bin/emacs" "HISTSIZE=5000"
"PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/ant/bin:/opt/ant/bin"
"LARCH_PATH=/usr/share/splint/lib" "ANT_HOME=/opt/ant"
"XAUTHORITY=/home/*****/.Xauthority" "XDG_RUNTIME_DIR=/run/user/1000"
"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus" "LOGNAME=*****"
"IRC_CLIENT=irssi" "SHLVL=3" "XDG_SEAT=seat0" "AUTOFEATURE=true autotest"
"TERM=dumb" "SHELL=/bin/bash" "WINDOWPATH=1" "VISUAL=emacsclient -c -a
emacs" "MAIL=/var/spool/mail/*****"
"_JAVA_OPTIONS=-Dsun.java2d.opengl=true" "GTK_MODULES=canberra-gtk-module"
"ALTERNATE_EDITOR=emacsclient -c -a emacs" "HOME=/home/*****"
"PWD=/home/*****/emacs" "TERMINOLOGY=1" "LSCOLORS=Gxfxcxdxdxegedabagacad"
"USER=*****" "XDG_SESSION_ID=c1" "HG=/usr/bin/hg" "SCM_CHECK=true"
"GIT_HOSTING=[email-masked]" "XDG_VTNR=1"
"JAVA_HOME=/usr/lib/jvm/default/jre"
"LCLIMPORTDIR=/usr/share/splint/imports" "EDITOR=emacsclient -t -a emacs
-t" "TODO=t" "HISTCONTROL=ignorespace:erasedups" "HISTIGNORE=pwd:ls:ls
-l:cd:cd ..:cd -:cd --" "TZ=:/etc/localtime" "LANG=sv_SE.UTF-8"
"DICPATH=/home/*****/.emacs.d/hunspell" "BASH_IT=/home/*****/.bash-it"
"BASH_IT_THEME=bobby" "XTERM_256_COLORS=1"
"LD_LIBRARY_PATH=:/usr/local/lib:/usr/local/lib" "GREP_COLOR=1;33")

When I run M-x ispell-buffer-with-debug, I get same backtrace as posted in
my original message. I also get following (*ispell-debug* buffer):

-- ispell-fhd: Skipping entry: AVAILABLE DICTIONARIES (path is not
mandatory for -d option):
-- ispell-fhd: Skipping entry: Can't open affix or dictionary files for
dictionary named "sv_SE".

I don't know it says it can't open entry, since I can see the dictionary,
and when started from shell, emacs has no problem opening it :).

I have to admit that I am not very proficient using edebug. To be honest I
have no idea how to step through code properly with it, and manual does
not give me much clues. It list all commands but one to use to step
through. I am probably just not smart enough to understand it. Anyway
stacktrace was gigantic, about 20 lines tall, but about 7800 chars wide so
I am not posting it here. But help how to step through and find more info
is appreciated.

2017-08-09 22:00 GMT+02:00 Glenn Morris <[email-masked]>:

> Arthur Miller wrote:
>
> > I have checked that all paths are setup correctly. Emacs finds
> > dictionaries (DICPATH setts correctly in systemd service file),
> > and it also finds spellchecking program (/usr/bin/hunspell).
> >
> > I believe it might be something with passing strings to and from
> > d-bus, but I don't have experience with d-bus at all so I really
> > don't know.
>
> I don't see what D-Bus would have to do with this.
> I imagine that the environment of Emacs when started from systemd is
> different from when you start it normally, and something is missing that
> means hunspell can't find its dictionaries.
>
> You might compare the value of 'process-environment' in the two Emacs to
> see what differs. Or M-x ispell-buffer-with-debug might provide more
> information. Or edebug ispell-find-hunspell-dictionaries and step
> through it to see where things go wrong.
>
>
>