Modify run command to detect the environment.