This is because the operating system resets the environment so that it only contains the LOGNAME, SHELL, USER, USERNAME, and SUDO_ variables by default. As a result, EGO_CONFDIR is not set in the sudo environment. Add the following line to the top of the /etc/sudoers file to preserve all the user environment variables when using "sudo":
Alternatively, you can use "sudo -E <cmd>" to work around this if the sudo version on the machine is newer than 1.6.9: