GothenburgBitFactory / tasklib

A Python library for interacting with taskwarrior databases.
http://tasklib.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
146 stars 27 forks source link

Getting errors in hook when running task command from an external script #108

Closed sdondley closed 2 years ago

sdondley commented 2 years ago

Running taskwarrior 2.6.1 with latest version of tasklib, python 3.9 installed with homebrew on mac.

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 called Karabiner Elements. Karabiner calls a simple 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 generated 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). I'm totally unfamiliar with python environment and libraries so a hand would be greatly appreciated.

sdondley commented 2 years ago

I just found the pirate hook repo. Closing this issue here and opening over there instead: https://github.com/tbabej/taskpirate/issues/17