marvel-nccr / quantum-mobile

A Virtual Machine for computational materials science
https://quantum-mobile.readthedocs.io
Other
90 stars 31 forks source link

Fix `tox -e vagrant` for Linux #188

Open chrisjsewell opened 3 years ago

chrisjsewell commented 3 years ago

Thanks to feedback by @borellim, it appears that there is an issue running tox -e vagrant on Linux, whereby it does not propagate the required environmental variables, and you end up with:

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "b6fc79cc-56c3-456b-b082-a1b2844ae8dc", "--type", "gui"]
Stderr: VBoxManage: error: The virtual machine 'Siesta Mobile 0.1.0' has terminated unexpectedly during startup with exit code 1 (0x1)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine
ERROR: InvocationError for command /usr/bin/vagrant up (exited with code 1)

To ensure environment isolation, tox only propagates a number of core environmental variables, and then anything you specify in passenv. Currently, this set up works on Mac but apparently not LinuX:

[testenv:vagrant]
description = Build a vagrant box VM then provision with ansible
deps = -rrequirements.txt
passenv =
    HOME
    ANSIBLE_ARGS
    VAGRANT_NO_GUI
    VAGRANT_ON_GH
    BUILD_PLAYBOOK
whitelist_externals = vagrant
commands_pre =
    ansible-galaxy install -r requirements.yml
commands = vagrant {posargs:up}

Now you can set passenv = *, to pass all environmental variables, and this "fixed" it for @borellim. But it would be ideal to identify the exact additional variables that need to be passed.

@borellim provided this list of environmental variable names he had in the parent terminal:

CLUTTER_IM_MODULE
COLORTERM
DBUS_SESSION_BUS_ADDRESS
DEFAULTS_PATH
DESKTOP_AUTOSTART_ID
DESKTOP_SESSION
DISPLAY
GDMSESSION
GNOME_DESKTOP_SESSION_ID
GNOME_SHELL_SESSION_MODE
GNOME_TERMINAL_SCREEN
GNOME_TERMINAL_SERVICE
GPG_AGENT_INFO
GTK_IM_MODULE
GTK_MODULES
HOME
IM_CONFIG_PHASE
LANG
LC_ADDRESS
LC_IDENTIFICATION
LC_MEASUREMENT
LC_MONETARY
LC_NAME
LC_NUMERIC
LC_PAPER
LC_TELEPHONE
LC_TIME
LESSCLOSE
LESSOPEN
LOGNAME
LS_COLORS
MANDATORY_PATH
PATH
PWD
QT4_IM_MODULE
QT_ACCESSIBILITY
QT_IM_MODULE
SESSION_MANAGER
SHELL
SHLVL
SSH_AGENT_PID
SSH_AUTH_SOCK
S_COLORS
TERM
TEXTDOMAIN
TEXTDOMAINDIR
USER
USERNAME
VTE_VERSION
WINDOWPATH
XAUTHORITY
XDG_CONFIG_DIRS
XDG_CURRENT_DESKTOP
XDG_DATA_DIRS
XDG_MENU_PREFIX
XDG_RUNTIME_DIR
XDG_SEAT
XDG_SESSION_DESKTOP
XDG_SESSION_ID
XDG_SESSION_TYPE
XDG_VTNR
XMODIFIERS
chrisjsewell commented 3 years ago

If possible @borellim, It would be good if you could try narrowing down what ones need to be added, e.g. a classic bisection approach; add half of them to tox.ini, run vagrant destroy then tox -e vagrant and see if you still get the error, rinse and repeat