-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
pip virtualenv creates chdir twice when using a relative path #81522
Comments
Files identified in the description: If these files are incorrect, please update the |
First part of the problem here is I think that the virtualenv is created twice because the above playbook specifies it twice. Once in Second part of the problem is that it looks like specifying As a workaround (or working solution?) this should work: - hosts: localhost
gather_facts: false
tasks:
- git:
repo: https://github.com/timofurrer/try
version: master
dest: /tmp/checkout-dir
- pip:
chdir: /tmp/checkout-dir
requirements: requirements.txt
virtualenv: venv
virtualenv_command: python3 -m venv |
With this in mind the behaviour seems that update: it seems
It does work for me, and in my experience is relative to the working directory of the target (usually the home directory on a remote host). I've relied on this behaviour in most of my playbooks, whether or not it's defined. |
Interesting, with - hosts: container
gather_facts: false
tasks:
- git:
repo: https://github.com/timofurrer/try
version: master
dest: /checkout-dir
- pip:
chdir: checkout-dir
requirements: requirements.txt
virtualenv: venv
virtualenv_command: python3 -m venv I get:
because the virtualenv is created in The following POC patch seems to fix the problem: diff --git a/lib/ansible/modules/pip.py b/lib/ansible/modules/pip.py
index 9a3daf61b80..da7a33cd19d 100644
--- a/lib/ansible/modules/pip.py
+++ b/lib/ansible/modules/pip.py
@@ -686,8 +686,10 @@ def main():
env = module.params['virtualenv']
venv_created = False
- if env and chdir:
- env = os.path.join(chdir, env)
+ if env:
+ if chdir:
+ env = os.path.join(chdir, env)
+ env = os.path.abspath(env)
if umask and not isinstance(umask, int):
try: |
Summary
pip
module creates thechdir
argument twice when creating a virtual environment throughvenv
.Issue Type
Bug Report
Component Name
pip
Ansible Version
Configuration
OS / Environment
Targeting Ubuntu 18.04.05, Python 3.6
Steps to Reproduce
Run below playbook.
(arbitrary repository reproducing the issue)
Expected Results
Ansible creates
checkout-dir/venv
containing a virtual environment with packages fromcheckout-dir/requirements-dev.txt
.Actual Results
Ansible creates virtual environments at both
checkout-dir/venv
andcheckout-dir/checkout-dir/venv
, but only the latter contains packages fromrequirements.txt
.Code of Conduct
The text was updated successfully, but these errors were encountered: