GothenburgBitFactory / tasklib

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

Extracting Taskwarrior version method issue #89

Closed leikoilja closed 3 years ago

leikoilja commented 3 years ago

I'm getting an error when running a cronjob that is supposed to sync tasks. In short, the error traceback boils down to the place to the backend.py file TaskWarrior client:

    def _get_version(self):
        p = subprocess.Popen(
            self._get_task_command() + ['--version'],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        stdout, stderr = [x.decode('utf-8') for x in p.communicate()]
        return stdout.strip('\n')

running the subprocess.Popen where self._get_task_command() is returning task

Traceback (most recent call last):
...
  File "/Users/leikoilja/Development/Envs/nvim/lib/python3.8/site-packages/tasklib/backends.py", line 112, in __init__
    self.version = version_override or self._get_version()
  File "/Users/leikoilja/Development/Envs/nvim/lib/python3.8/site-packages/tasklib/backends.py", line 151, in _get_version
    p = subprocess.Popen(
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'task'

The weird part is that when I run task --version from my user it returns 2.5.1, but using a job through crontab -e(these jobs should run using the same user) it ends up in the error.

leikoilja commented 3 years ago

Ops, sorry, just realized it's the problem of how the 3rd party package is implemented that I am using for cronjob. My solution is open PR in the 3rd party package to specify task_command="/usr/local/bin/task" when initializing TaskWarrior client