magento2: Magento 2 CLI Installation fails

Preconditions (*)

  1. Have GiT installed
  2. Have docker installed
  3. Clone the magento2 project with branch (2.4-develop, commit: ad2945209811dc9fb5cd531af8f2a2bace8647f3)
  4. Have PHP CLI version 7.4.10 installed
  5. Have MariaDB Percona Server 5.7.32-35 installed

Steps to reproduce (*)

  1. Create an mariadb and php docker image
  2. Configure Magento to use proper credentials/hosts
  3. Run composer install
  4. Run bin/magento setup:install (or follow command(s) in https://devdocs.magento.com/guides/v2.4/install-gde/install/cli/install-cli-install.html or https://devdocs.magento.com/guides/v2.4/install-gde/install/cli/install-cli-subcommands.html)

Expected result (*)

  1. Magento 2 installs or fails on missing parameters.

Actual result (*)

  1. The installation fails on step 4 with “The default website isn’t defined. Set the website and try again.” Screenshot from 2020-12-15 09-29-27

What I have done so far:

  • Clear all cache
  • Try a different setup command (see links step 3 reproduce)
  • Re-create database
  • Composer install without dev packages

It appears to be related to https://github.com/magento/magento2/issues/27864 and https://github.com/magento/magento2/issues/15196 and maybe https://github.com/justbetter/magento2-sentry/issues/23

It is also important to note that when the install fails the database is still empty and no tables have been created yet.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 20 (4 by maintainers)

Most upvoted comments

I just ran into almost the same; with a little different setup. I’m using the containers found here, but the error was identical. It appears to have fixed itself after I ran bin/magento setup:db-schema:upgrade, which will fail, but then the setup:install command will suddenly work…

I’ve found a way to make it work (it’s a workaround rather than an actual solution) :

  • disable custom modules during install with --disable-modules
  • re enable modules afterwards
  • update db schema and data
pimpmylog "running magento installation" $YELLOW
composer install -d $WEB_DIR && \
$WEB_DIR/bin/magento setup:install \
--base-url=$URL --backend-frontname=$BACKEND_FRONTNAME \
--language=$LANGUAGE --timezone=$TIMEZONE \
--currency=$DEFAULT_CURRENCY --db-host=$MYSQL_HOST \
--db-name=$MYSQL_DATABASE --db-user=$MYSQL_USER \
--db-password=$MYSQL_PASSWORD --use-secure=$USE_SECURE \
--use-secure-admin=$USE_SECURE_ADMIN --session-save-redis-host=$REDIS_HOST \
--cache-backend-redis-server=$REDIS_HOST --cache-backend=redis \
--admin-firstname=$ADMIN_FIRSTNAME \
--admin-lastname=$ADMIN_LASTNAME --admin-email=$ADMIN_EMAIL \
--admin-user=$ADMIN_USERNAME --admin-password=$ADMIN_PASSWORD \
--disable-modules=$DISABLE_MODULE --elasticsearch-host=$ES_HOST \
--session-save=redis --use-rewrites=1 --cleanup-database 

pimpmylog "enabling modules back " $YELLOW
for module in $(echo $DISABLE_MODULE | sed "s/,/ /g");do
    if [[ $module != "Magento_TwoFactorAuth" ]];then
        $WEB_DIR/bin/magento module:enable $module 
    fi
done

pimpmylog "upgrade data & schema " $YELLOW
$WEB_DIR/bin/magento setup:db-data:upgrade 
$WEB_DIR/bin/magento setup:db-schema:upgrade 

pimpmylog "Magento installation done" $GREEN

(2factor auth is kept disabled for local developements purposes)

@manobi I’ve same issue with PHP 7.4.15 run bin/magento setup:upgrade

Module 'PayPal_Braintree':
Installing schema... Killed

I reverted to using PHP 7.3, all worked fine.

Hello thank you for checking it out. A configured env.php is needed for the database config (I should have added it, nice catch) and that is it. Once it reaches step 4 out of 841 it fails with the exact same error I just tested it with the latest 2.4-develop and the issue still exists.

Which version of php/db did you use? Maybe the issue is related to that? Or maybe it is a container specific issue.

That does indeed work as a quick fix, thank you for that. I still believe it should have some investigation because why does the setup try to access database values before the database is set-up?