docker-magento icon indicating copy to clipboard operation
docker-magento copied to clipboard

Fix: avoid 'Warning: magento.env file not found' when running bin/setup

Open angelvilaplana opened this issue 2 months ago • 3 comments

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:

image

Also, when the env file was not found, the admin credentials did not appear in the output:

image

Changes

  • Added a check for ./env/magento.env before 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:
image

angelvilaplana avatar Oct 12 '25 17:10 angelvilaplana

PR Summary

  • Updated magento.env File Path Instead of checking the parent directory first, the system will now initially look in the current directory for the magento.env file.

  • Enhanced Logic for Sourcing Environment File If the magento.env file 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.

what-the-diff[bot] avatar Oct 12 '25 17:10 what-the-diff[bot]

Looks like shellcheck is failing. Besides that, why would the env directory be located at src/env? This is a non-standard location.

markshust avatar Oct 21 '25 13:10 markshust

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.

angelvilaplana avatar Oct 21 '25 14:10 angelvilaplana