More robust use of our virtualenv #1412
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Prior to this change, the script tests if it's running inside a
virtualenv; and if it is, it assumes that it must be inside its own
virtualenv.
This change switches to testing for the activate binary in the
place we expect; and if it's found, using it directly. This avoids
false positives (running the script inside the wrong virtualenv) and
makes sure that we're running from inside the right
virtualenv.
Motivation and Context
I routinely run everything inside a virtualenv. This broke the script for me; it detected that it was inside a virtualenv and so it didn't attempt to activate its own virtualenv, so it couldn't find the ansible-playbook binary.
The existing docs at https://github.com/trailofbits/algo/blob/master/docs/troubleshooting.md#error-ansible-playbook-command-not-found boldly state that "You did not finish step 4 in the installation instructions". This is not correct: I did finish step 4; but the script did not use the virtualenv created in step 4.
How Has This Been Tested?
I ran it once on my machine and it worked for me.
Types of changes
Checklist:
I'm not sure if the doc section I mentioned should change. I think the docs are more correct after this change than they were before