StackStorm / StackStorm/st2

PYTHONPATH doesn't include the virtualenv path in python2

Open
#4,812 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug status:to be verified
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

SUMMARY

When running an action the PYTHONPATH isn't set to include the virtual environment path if the action uses python2. It is added for python3

STACKSTORM VERSION

Paste the output of st2 --version:

st2 3.1.0, on Python 2.7.5
OS, environment, install method

Installed on a centos bare metal machine with the ansible-st2

Steps to reproduce the problem

Install the openstack pack and attempt to run a command. This leads to it finding an incorrect version of the osc_lib due to it not looking in it's virtualenv.

Expected Results

Expected the action to look in the virtual environment for the library first.

Actual Results

It looked in the global system location for python libs and found the incorrect version.

Extra

I think the issue is around here: line

It gets the virtualenv path, then only adds it if python3 is used.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in st2common/st2common/util/sandboxing.py around the referenced line, where the virtualenv path is obtained and added for Python 3. Reproduce the problem by running an action from the openstack pack with Python 2 and inspect which osc_lib version is found. Done means Python 2 actions search the virtual environment before the global system location.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.