Virtualenv fails in CI

Hi,

We use Python 2.x + django.
When we run ci, we were faced with the following such event.

If cache file (MACHINE section) has home/ubuntu/virtualenvs, our test are executable.

  • Restore cache
restoring cache v5/os:linux/OUR_TEAM/OUR_PROJECT/dependency/SOME_BRANCH/1167/aaaaaaaaaaaaaaaaaaaaaa__.tar.gz
restoring home/ubuntu/virtualenvs, home/ubuntu/.m2, home/ubuntu/.ivy2,     home/ubuntu/.go_workspace, home/ubuntu/.gradle
  • virtualenv
Using cached venv

But, if cache file does not have it, our test fail at MACHINE:virtualenv step.

  • Restore cache
restoring cache v5/os:linux/OUR_TEAM/OUR_PROJECT/dependency/SOME_BRANCH/1235/aaaaaaaaaaaaaaaaaaaaaa__.tar.gz
restoring home/ubuntu/.m2, home/ubuntu/.ivy2, home/ubuntu/.go_workspace, home/ubuntu/.gradle
  • virtualenv
((if (directory? "/home/ubuntu/virtualenvs/venv-2.7.5") (echo "Using cached venv") (do ("virtualenv" "/home/ubuntu/virtualenvs/venv-2.7.5" || exit 1) (source "/home/ubuntu/virtualenvs/venv-2.7.5/bin/activate" || exit 2) (pip install nose || exit 3))) "rm -rf venv; ln -s /home/ubuntu/virtualenvs/venv-2.7.5 venv" (echo "source /home/ubuntu/virtualenvs/venv-2.7.5/bin/activate" >> "~/.circlerc")) returned exit code 1

pyenv: version `venv' is not installed (set by /home/ubuntu/OUR_PROJECT/.python-version) Action failed: virtualenv

Why there are cases that does not include ‘home/ubuntu/virtualenvs’ ?
Can I control it ?

Please help us if you know about this.
regards,

Are you selecting a specific Python version in your circle.yml?

Could you please try adding sudo pip install virtualenv to the machine: pre section and check if that helps?

alexey, thank you.

Yes, we select specifil Python version.

In conclusion, it is still fail.

We updated as follow:

circle.yml

machine:
  python:
    version: 2.7.5
  pre:	
    - sudo pip install virtualenv	

Executed CI,

$ sudo pip install virtualenv section add to MACHINE area.
But it failed in the same way as the previous

  • $ sudo pip install virtualenv
$ sudo pip install virtualenv
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/dist-packages
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
  • Restore cache
restoring cache v5/os:linux/OUR_TEAM/OUR_PROJECT/dependency/modify_signup_page/1305/aaaaaaaaaaaaaaaaaaaaaa__.tar.gz
restoring home/ubuntu/.m2, home/ubuntu/.ivy2, home/ubuntu/.go_workspace, home/ubuntu/.gradle
  • virtualenv
((if (directory? "/home/ubuntu/virtualenvs/venv-2.7.5") (echo "Using cached venv") (do ("virtualenv" "/home/ubuntu/virtualenvs/venv-2.7.5" || exit 1) (source "/home/ubuntu/virtualenvs/venv-2.7.5/bin/activate" || exit 2) (pip install nose || exit 3))) "rm -rf venv; ln -s /home/ubuntu/virtualenvs/venv-2.7.5 venv" (echo "source /home/ubuntu/virtualenvs/venv-2.7.5/bin/activate" >> "~/.circlerc")) returned exit code 1

pyenv: version `venv' is not installed (set by /home/ubuntu/OUR_PROJECT/.python-version) Action failed: virtualenv

We remove sudo command, and re-run.
But it was same.

circle.yml

machine:
  python:
    version: 2.7.5
  pre:	
    - pip install virtualenv	
  • $ sudo pip install virtualenv
$ pip install virtualenv
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/dist-packages
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
  • Restore cache
restoring cache v5/os:linux/OUR_TEAM/OUR_PROJECT/dependency/modify_signup_page/1306/aaaaaaaaaaaaaaaaaaaaaa__.tar.gz
restoring home/ubuntu/.m2, home/ubuntu/.ivy2, home/ubuntu/.go_workspace, home/ubuntu/.gradle
  • virtualenv
((if (directory? "/home/ubuntu/virtualenvs/venv-2.7.5") (echo "Using cached venv") (do ("virtualenv" "/home/ubuntu/virtualenvs/venv-2.7.5" || exit 1) (source "/home/ubuntu/virtualenvs/venv-2.7.5/bin/activate" || exit 2) (pip install nose || exit 3))) "rm -rf venv; ln -s /home/ubuntu/virtualenvs/venv-2.7.5 venv" (echo "source /home/ubuntu/virtualenvs/venv-2.7.5/bin/activate" >> "~/.circlerc")) returned exit code 1

pyenv: version `venv' is not installed (set by /home/ubuntu/OUR_PROJECT/.python-version) Action failed: virtualenv

Please give me ideas.

regards,

I have fixed this issue at long last.

We added machine: pre section as blow.

circle.yml

machine:
  python:
    version: 2.7.5
  
  pre:
    - if [ ! -e '/home/ubuntu/virtualenvs/venv-2.7.5' ]; then mkdir -p '/home/ubuntu/virtualenvs'; pushd '/home/ubuntu/virtualenvs'; virtualenv venv-2.7.5; popd; fi
2 Likes