[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
mcron service and PATH (was: Home service for mbsync?)
From: |
Emmanuel Beffara |
Subject: |
mcron service and PATH (was: Home service for mbsync?) |
Date: |
Thu, 22 Feb 2024 13:37:10 +0100 |
Hello,
De Carlo Zancanaro le 22/02/2024 à 10:27:
> On Wed, Feb 21 2024, Felix Lechner via wrote:
> > Does anyone have an 'mbsync' home service, please? Thanks!
>
> I just run mbsync as an mcron service. I have a custom script, because I
> do some weird stuff to update my mu index afterwards, but it shouldn't
> be hard to figure out how to call mbsync directly.
>
> In my home services I have this:
>
> (simple-service 'mail-update-script
> home-mcron-service-type
> ;; Update email every five minutes.
> (list #~(job '(next-minute '(0 5 10 15 20 25 30 35 40 45
> 50 55))
> "/home/carlo/.local/bin/fetch-mail")))
>
> Obviously this doesn't handle configuring mbsync, which I do outside of
> my home configuration.
I'm doing something similar, with a custom script that calls mbsync and does
some additional stuff for indexing and tagging by notmuch.
I recently noticed an issue with that: it seems that the command in the mcron
job is called with an incomplete PATH. I diagnosed that by creating a
similar mcron job with the command "/usr/bin/env > ~/E". Apparently my user
profile (as defined in .profile, which is managed by guix home) is indeed
inherited by the job, except for PATH which is reset and just contains
/run/current-system/profile/bin.
This is problematic if the job wants to call a command that is not in the
system profile. A workaround would be to define the job with an explicit
reference to a package, like:
(service
home-mcron-service-type
(home-mcron-configuration
(jobs (list
#~(job
'(next-minute (range 0 60 5))
(string-append #$isync "/bin/mbsync inbox")
)))))
but this does not completely solve the issue since PATH is still reset and
any command that is called through mbsync (e.g. through a PassCmd setting)
will fail if it does not have an absolute path.
Is there a proper way to inherit PATH from the user profile in mcron jobs ?
--
Emmanuel