Fix: avoid 'Warning: magento.env file not found' when running bin/setup
Summary
Previously, the setup script only checked for ../env/magento.env.
As a result, when the magento.env file was located in ./env, the script showed the warning:
Also, when the env file was not found, the admin credentials did not appear in the output:
Changes
- Added a check for
./env/magento.envbefore checking../env/magento.env. - This ensures the environment file is sourced correctly.
Result
- The warning no longer appears when the file exists in the current directory.
- The admin credentials are now displayed correctly after setup:
PR Summary
-
Updated
magento.envFile Path Instead of checking the parent directory first, the system will now initially look in the current directory for themagento.envfile. -
Enhanced Logic for Sourcing Environment File If the
magento.envfile exists in the current directory, the system will source it from here. If not, the system will look in the parent directory as a backup option. This provides a more flexible and adaptive way of sourcing the necessary file.
Looks like shellcheck is failing. Besides that, why would the env directory be located at src/env? This is a non-standard location.
Hi @markshust,
Yes, you're right. The env folder is in the root directory, and the src folder is also in the root but in a different subfolder. However, even in this case, I’m still getting the same error. When I run bin/setup, it tries to execute outside the project folder, so the env file can’t be found.
Hmm, I see that the test is running ./compose/bin/setup. In my case, I run bin/setup to install the environment. It should still work anyway, since I added a condition to make sure the file ./env/magento.env exists before running the source command.