Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task module discovery goes on an unexpected journey #131

crccheck opened this issue Mar 19, 2014 · 1 comment

Task module discovery goes on an unexpected journey #131

crccheck opened this issue Mar 19, 2014 · 1 comment


Copy link

@crccheck crccheck commented Mar 19, 2014

The behavior invoke currently has for task module discovery: is counter to what I expect.

The Setup

I have my project with many dependencies, with a with invoke tasks in it. I type invoke. I'm using invoke==0.7.0

My expectation

Invoke discovers the tasks in

What actually happens

Invoke walks through my python path and finds a random tasks module in a random package and tries to run it instead and ends up waking a dragon. In another project with an older version of invoke, I know finds a for celery.


I would expect the tasks module discovery to find the same module that import tasks finds.

Copy link

@bitprophet bitprophet commented Apr 14, 2014

For some reasoning on the hybrid FS and sys.path approach, see #92 (comment) . Additionally, specific to your issue (which could otherwise be solved by ignoring sys.path) is the fact that folks may want to use a non-local, distributed-via-pip-install module's tasks module instead of one local to themselves. (E.g. inv -c othermodule.tasks.)

The real problem here, though, is that the feature is insufficiently thorough and doesn't ensure your local task module is first in the path in all situations, which leads to the scenario you described.

For example, we ran into the same thing just now here at Pycon sprints, with Invoke itself:

  • User installs invoke and its dev dependencies including invocations
  • invocations ends up on sys.path before invoke
  • inv -l now shows invocations''s contents (in this case just publish) instead of invoke's own (tests, docs etc.)
  • There was no way for the user to recover from this because it's entirely arbitrary depending on sys.path ordering.

The good news is we just fixed this by always unconditionally putting the local's containing directory first in sys.path, even if it's already in sys.path. This fix is in master now and will be out in the next bugfix release. Please reopen if it doesn't fix for you. Thanks!

@bitprophet bitprophet closed this Apr 14, 2014
bitprophet added a commit that referenced this issue Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants