ralphbean / taskw

python taskwarrior api
http://threebean.org
GNU General Public License v3.0
175 stars 47 forks source link

Pass taskrc via environment variable to subprocess. #134

Closed ryneeverett closed 3 years ago

ryneeverett commented 4 years ago

Based on #131.

I can't find where the rc:{config_filename} option is documented and it doesn't seem to work on taskwarrior 2.5.1.

The environment variable TASKRC overrides an rc:%s argument, which means if there is a TASKRC environment variable, it will override the value passed to config_filename. This is only a problem in TaskWarriorShellout because subprocess inherits the environment.

Alternatively, we could set env={} in the subprocess call to isolate the environment, but this would be a more aggressive change and might not be desirable.

I encountered this as a problem running the tests in an environment with the TASKRC variable defined, which causes the global taskrc (and therefore taskwarrior database) to be used by the test suite instead of the test configuration and database, which added a bunch of fake test data to my personal database. If this were the only issue we could do better environment isolation in the test suite. However, ignoring config_filename isn't desirable for taskw library users either.

coddingtonbear commented 4 years ago

Maybe not important, but I’m fairly sure rc: works in 2.5.1 b/c inthe.am relies on that feature.

mrossinek commented 4 years ago

I can confirm that task rc:<config file> works with 2.5.1. It is documented in the man page: https://github.com/GothenburgBitFactory/taskwarrior/blob/2.6.0/doc/man/task.1.in#L1306

ryneeverett commented 4 years ago

Thanks for the feedback. My reasoning was wrong but now that I understand it better I still think the patch is defensible. I've updated the PR description accordingly.