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

More robust use of our virtualenv #1412

Merged
merged 1 commit into from
Aug 15, 2019

Conversation

jamezpolley
Copy link
Contributor

@jamezpolley jamezpolley commented Apr 27, 2019

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

  • Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
    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
  • [] I have updated the documentation accordingly.
  • [] I have added tests to cover my changes.
  • [] All new and existing tests passed.

@CLAassistant
Copy link

CLAassistant commented Apr 27, 2019

CLA assistant check
All committers have signed the CLA.

@jamezpolley
Copy link
Contributor Author

An alternative to ./env/bin/ansible-playbook would be to revert line 8 to sourcingenv/bin/activate and line 5 testing for the presence of that script - ie, just take away the misleading and irrelevant check to see if we're already in a virtualenv

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 inside the right virtualenv.
@jamezpolley jamezpolley force-pushed the use-virtualenv-directly branch from 64a2d0d to 45c368b Compare April 28, 2019 00:00
@jamezpolley jamezpolley changed the title More robust use of ansible-playbook in our virtualenv More robust use of our virtualenv Apr 28, 2019
@jackivanov
Copy link
Collaborator

@jamezpolley Could you accept the CLA and we will merge this?

@jackivanov jackivanov merged commit 2909107 into trailofbits:master Aug 15, 2019
jackivanov added a commit that referenced this pull request Aug 22, 2019
jackivanov added a commit that referenced this pull request Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants