detect and fix environment files during installation, fix #2835, update #2817