USER env var does not always exist #367

Closed
ryan-beisner opened this Issue Oct 31, 2017 · 3 comments

Comments

Projects
None yet
1 participant

The latest stable release of charm tools causes the tool to fail when run by non-human users such as jenkins, where the USER env var is not defined.

See https://bugs.launchpad.net/charm-test-infra/+bug/1728680

This is where the issue was introduced: #349

====>  Building /var/lib/jenkins/checkout/37/designate (designate)  <=======================
 + Enabling HTTP(S) proxies.
 + Autodetected charm name as: designate
 . Building /var/lib/jenkins/checkout/37/designate (designate) via tox
build create: /var/lib/jenkins/checkout/37/designate/.tox/build
build installdeps: -r/var/lib/jenkins/checkout/37/designate/requirements.txt
build installed: asn1crypto==0.23.0,blessings==1.6,cffi==1.11.2,charm-tools==2.2.2,Cheetah==2.4.4,colander==1.0b1,configparser==3.5.0,cryptography==2.1.2,ecdsa==0.13,enum34==1.1.6,flake8==3.5.0,functools32==3.2.3.post2,httplib2==0.10.3,idna==2.6,ipaddress==1.0.18,jsonschema==2.5.1,jujubundlelib==0.5.5,keyring==10.4.0,launchpadlib==1.10.5,lazr.restfulclient==0.13.5,lazr.uri==1.0.3,libcharmstore==0.0.7,Markdown==2.6.9,mccabe==0.6.1,oauth==1.0.1,otherstuf==1.1.0,paramiko==1.18.4,parse==1.8.2,path.py==8.1.2,pathspec==0.3.4,pbr==3.1.1,pkg-resources==0.0.0,pycodestyle==2.3.1,pycparser==2.18,pycrypto==2.6.1,pyflakes==1.6.0,PyYAML==3.11,requests==2.9.1,ruamel.base==1.0.0,ruamel.ordereddict==0.4.13,ruamel.yaml==0.10.23,SecretStorage==2.3.1,simplejson==3.11.1,six==1.11.0,stuf==0.9.16,testresources==2.0.1,theblues==0.3.8,translationstring==1.3,virtualenv==15.1.0,wadllib==1.3.2
build runtests: PYTHONHASHSEED='0'
build runtests: commands[0] | charm-build --log-level DEBUG -o /var/lib/jenkins/checkout/37/designate/build src
Traceback (most recent call last):
  File ".tox/build/bin/charm-build", line 11, in <module>
    sys.exit(main())
  File "/var/lib/jenkins/checkout/37/designate/.tox/build/local/lib/python2.7/site-packages/charmtools/build/builder.py", line 747, in main
    build.check_paths()
  File "/var/lib/jenkins/checkout/37/designate/.tox/build/local/lib/python2.7/site-packages/charmtools/build/builder.py", line 593, in check_paths
    if path_to_check and not self._check_path(path_to_check):
  File "/var/lib/jenkins/checkout/37/designate/.tox/build/local/lib/python2.7/site-packages/charmtools/build/builder.py", line 579, in _check_path
    home_dir = os.path.expanduser('~{}'.format(os.environ['USER']))
  File "/var/lib/jenkins/checkout/37/designate/.tox/build/lib/python2.7/UserDict.py", line 40, in __getitem__
    raise KeyError(key)
KeyError: 'USER'

ryan-beisner commented Oct 31, 2017

This has stopped the line in OpenStack Charms dev/test/release automation. We can add glue to export a USER env var if necessary, but wanted to raise this here as it may break other people too. Please advise.

A work-around for us would require modification of 30+ tox.ini files to ensure USER env var is passed to virtualenvs.

johnsca added a commit that referenced this issue Oct 31, 2017

@johnsca johnsca referenced this issue Oct 31, 2017

Merged

Don't rely on any env vars to determine $HOME #368

4 of 4 tasks complete

johnsca added a commit that referenced this issue Oct 31, 2017

@johnsca johnsca closed this in #368 Oct 31, 2017

johnsca added a commit that referenced this issue Oct 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment