Recently I noticed that I can't access my mails through IMAP. As it turns out, dovecot service fails to start, leaving only this error message in dinit's log:
Fatal: t_binary_abspath(dovecot) failed: PATH environment variable undefined
Though when manually run from shell, it works just fine. I tried to disable the service, remove and reinstall it, but to no avail. I'm baffled.
Is there a way you can set environment variables in dinit service files?
There is. Infact, dovecot does have its own run script in /etc/dinit.d/scripts . Do I set the PATH there? To what value?
Found the appropriate code in dovecot:
} else if ((path_env = getenv("PATH")) != NULL) {
/* we have to find our executable from path */
path = t_str_new(256);
paths = t_strsplit(path_env, ":");
for (; *paths != NULL; paths++) {
str_append(path, *paths);
str_append_c(path, '/');
str_append(path, *binpath);
if (access(str_c(path), X_OK) == 0) {
*binpath = str_c(path);
return TRUE;
}
str_truncate(path, 0);
}
*error_r = "Could not find the wanted executable from PATH";
return FALSE;
} else {
*error_r = "PATH environment variable undefined";
return FALSE;
}
So yes, for some reason when started from a dinit service file, PATH is not set.
>Do I set the PATH there? To what value?
To your standard locations like /usr/bin and /usr/sbin
PATH variable should not be undefined in first place
Edit: switch to root user, then run
echo $PATH
check does it give output
adding export PATH before exec dovecot -F fixed the problem. Still, it's strange it had to be fixed in the first place, when it used to 'just work'.
Maybe an update on dinit broke it?
Hard to tell. Anyway, for now the problem is solved. I'd like to mark it as such, but somehow that forum button is now missing... Oh well.
I don't think there have been any recent updates to the Artix dinit packages (and I don't think there are any upstream changes that would cause this, though the environment handling has been reworked a little).