Re: mcron service and PATH (was: Home service for mbsync?)

2024-02-22 Thread Felix Lechner via
Hi,

> you can find it here
> I've attached my mbsync service
> I just run mbsync as an mcron service.
> +1! I also run it using mcron.
> In my home services I have this:
> I'm doing something similar

First off, thanks for all your responses so far!

On Thu, Feb 22 2024, Emmanuel Beffara wrote:

> the command in the mcron job is called with an incomplete PATH.

Has anyone noticed a similar PATH issue with system Mcron jobs?  I have
to do this inside my Mcron jobs:

(setenv "PATH"
(string-join (list "/run/setuid-programs" (getenv "PATH")) ":"))

Otherwise, the setuid copies of my executables like 'sendmail' are not
available in Mcron jobs.

Also, while I have your attention, my fellow Mcron aficionados, please
feel free to check out this little issue. [1] There goes another
afternoon...

Kind regards
Felix

[1] https://lists.gnu.org/archive/html/bug-mcron/2023-12/msg1.html



Re: mcron service and PATH (was: Home service for mbsync?)

2024-02-22 Thread Emmanuel Beffara
Hi,

De Tanguy LE CARROUR le 22/02/2024 à 14:51:
> Quoting Emmanuel Beffara (2024-02-22 13:37:10)
> > I recently noticed an issue with that: it seems that the command in the 
> > mcron
> > job is called with an incomplete PATH.
> 
> Yes, indeed.
> 
> The "problem" was discussed, among other places, here:
> .

Ha. I did receive this thread but didn't read it enough to realize this was
actually the cause of my problem (symptom: mail was not fetched automatically
anymore, it turns out the reasons were essentially the same as in your case).

> Long story short: I decided to put (or inject) the full path in all my
> config files.

My current fix is to prefix the job command with “source ~/.profile;” and keep
the config files otherwise unchanged.

Thanks !

-- 
Emmanuel



Re: mcron service and PATH (was: Home service for mbsync?)

2024-02-22 Thread Tanguy LE CARROUR
Hi Emmanuel,


Quoting Emmanuel Beffara (2024-02-22 13:37:10)
> 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 recently noticed an issue with that: it seems that the command in the mcron
> job is called with an incomplete PATH.

Yes, indeed.

The "problem" was discussed, among other places, here:
.

Long story short: I decided to put (or inject) the full path in all my
config files.

-- 
Tanguy



mcron service and PATH (was: Home service for mbsync?)

2024-02-22 Thread Emmanuel Beffara
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