canonical/layer-basic

use_venv: False breaks install hook

AdamIsrael opened this issue · 0 comments

Charms with use_venv set to False will break during the install hook.

ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Traceback (most recent call last):
  File "hooks/install", line 8, in <module>
    basic.bootstrap_charm_deps()
  File "lib/charms/layer/basic.py", line 117, in bootstrap_charm_deps
    glob('wheelhouse/*'))
  File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['pip3', 'install', '-U', '--no-index', '-f', 'wheelhouse', 'wheelhouse/pip-19.1.1.tar.gz', 'wheelhouse/PyYAML-5.1.2.tar.gz', 'wheelhouse/six-1.12.0.tar.gz', 'wheelhouse/charms.reactive-1.2.1.tar.gz', 'wheelhouse/netaddr-0.7.19.tar.gz', 'wheelhouse/pyaml-19.4.1.tar.gz', 'wheelhouse/setuptools_scm-1.17.0.tar.gz', 'wheelhouse/Tempita-0.5.2.tar.gz', 'wheelhouse/ecdsa-0.13.2.tar.gz', 'wheelhouse/paramiko-1.16.3.tar.gz', 'wheelhouse/wheel-0.33.4.tar.gz', 'wheelhouse/charmhelpers-0.20.1.tar.gz', 'wheelhouse/Jinja2-2.10.1.tar.gz', 'wheelhouse/setuptools-41.1.0.zip', 'wheelhouse/MarkupSafe-1.1.1.tar.gz', 'wheelhouse/pycrypto-2.6.1.tar.gz']' returned non-zero exit status 1

Steps to recreate:

  1. Create a new charm
  2. Edit layers.yaml and set use_venv to False:
options:
    basic:
        use_venv: False
  1. charm build
  2. Deploy built charm

Workaround

I've found a manual way to resolve and move past the error:

  1. Intercept the hook via juju debug-hooks $unit install
  2. Run pip3 install -U -f wheelhouse wheelhouse/PyYAML-5.1.2.tar.gz --ignore-installed
  3. Run hooks/install