0

I perl script that runs the following command:

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

The script works fine when the perl script is run from the command line. The command executes some python code in a library, tasklib, to insert a task into a TaskWarrior database.

However, when the perl script is executed indirectly by an app, Karabiner Elements, I get errors.

Some debug statements reveal this when the perl script is run standalone:

Python version: 3.9.9
Python bin: /usr/local/bin/python3

However, when Karabiner executes the perl script, I see:

Python version: 3.8.9
Python bin: /usr/bin/python3

So an older 3.8 version of tasklib is getting used. I need to somehow to tell bash to use the 3.9.9 version of python so it can find the newer tasklib library found in /usr/local/lib/python3.9/site-packages. How do I do this?

Barmar
  • 741,623
  • 53
  • 500
  • 612
StevieD
  • 6,925
  • 2
  • 25
  • 45
  • 1
    Put `/usr/local/bin` ahead of `/usr/bin` in your `PATH` environment variable. – Barmar Dec 07 '21 at 22:06
  • Thanks. But looks like that's already the case at least in my interactive terminal. `/usr/local/bin:/usr/bin`. How might I check that with the system bash, which I assume karabiner is using. – StevieD Dec 07 '21 at 22:12
  • Where is python being run from? – Barmar Dec 07 '21 at 22:13
  • An app called Karabiner Elements runs: `/usr/local/bin/bash -c '~/bin/taskwiki_helper.pl watchlist'`. The perl script it executes does: `/usr/local//bin/bash -c 'TASKRC=$ENV{HOME}/.taskrc /usr/local/bin/task`. This in turn calls some python code. The python code is what is choking because it's using an old library. – StevieD Dec 07 '21 at 22:19
  • They python code that chokes is a custom hook to the `tasklib` library which has the code to modify `TaskWarrior`. That code is here: https://github.com/tbabej/taskpirate/blob/master/on-add-pirate – StevieD Dec 07 '21 at 22:21

1 Answers1

2

Perhaps

/bin/bash -c 'PATH=/usr/local/bin:$PATH; TASKRC=/Users/me/.taskrc task add "the task"'
glenn jackman
  • 238,783
  • 38
  • 220
  • 352