reordered formula installation steps

check dependencies first
initialize the module environment only once right before install