1

I'm using taskwarrior with a couple of python hooks installed that get triggered when issuing certain taskwarrior commands. The hooks run fine when I use taskwarrior normally from the command line.

But I'm running into problems when the the hooks are trigged by a hotkey app, Karabiner Elements (I'm on a mac). Karabiner calls a perl script which in turn execute this bash command containing the task command:

/bin/bash -c 'TASKRC=/Users/me/.taskrc /usr/local/bin/task add \'the task\''

Unfortunately, the stack error is cutoff in the Karabiner log. This is as much as I get:

[2021-12-07 06:24:51.797] [error] [console_user_server] shell_command stderr:Traceback (most recent call last):   File "/Users/me/.task_work/hooks/on-add-pirate", line 9, in <module>     from tasklib import TaskWarrior, Task   File "/Users/me/Library/Python/3.8/lib/python/site-packages/tasklib/__init__.py", l...

I'm guessing the python script is choking because it can't figure out where needed libraries are. But I don't see any shell environment variables that I might be able to set. I have python3 installed with brew and the tasklib library installed with pip3 (I believe).

Here's the hook script:

#!/usr/bin/env python3

import glob
from types import ModuleType
from importlib.machinery import SourceFileLoader, ModuleSpec
from importlib.util import module_from_spec
import os

from tasklib import TaskWarrior, Task

<-- snip -->

task = Task.from_input()

for hook in find_hooks('pirate_add'):
    hook(task)

print(task.export_data())

And here's the __init__.py script mentioned in the error:

from .backends import TaskWarrior
from .task import Task
from .serializing import local_zone

__version__ = '2.2.1'

StevieD
  • 6,925
  • 2
  • 25
  • 45

1 Answers1

0

Ok, problem was bash was defaulting to older version of python3.

The fix is here: https://stackoverflow.com/a/70267561/1641112

StevieD
  • 6,925
  • 2
  • 25
  • 45