26

When I try to upgrade Magento 2 php bin/magento setup:upgrade I get

I get

[Magento\Setup\Exception]
Can't run this operation: deployment configuration is absent. Run 'magento setup:config:set --help' for options. setup:upgrade

[--keep-generated] [--magento-init-params="..."]

How to fix it? Updating using the web updater gives the following errors:

enter image description here

I asked my hosting provider to fix them and they did install the right php version 5.6 and all extensions recommended by magento and created a cron job but I still see the error.


UPDATE: (from comments)
env.php wasn't there, when I run magento setup:config:set I get this error:

$ bin/magento setup:config:set
SQLSTATE[HY000] [2002] No such file or directory

[InvalidArgumentException]
Parameter validation failed

3
  • 1
    Check to see if <magento install dir>/app/etc/env.php is present. That is the deployment configuration. If it's absent, run the magento setup:config:set command again to create it. Jun 22, 2016 at 0:16
  • @SteveJohnson env.php wasn't there, when I run magento setup:config:set i get this error pastebin.com/BDzxYGGU
    – Lynob
    Jun 22, 2016 at 7:51
  • The error indicates your Magento database user name and password don't match. I'm not sure it's a good idea to run your Magento database as root; have you seen our MySQL setup instructions? Maybe try that and see if the command succeeds. Jun 22, 2016 at 22:33

5 Answers 5

15

I ran into the same issue today. It appeared that the app/etc/env.php was missing. This means that Magento was not yet installed. During Magento installation it will create this file, so:

  • make sure app/etc/ is writable for the magento user/webuser
  • run bin/magento setup:install ...params...

In my case, some script that I made was not copying my env.php file into the app/etc/ folder.

It is also possible that the file is there, but it is not readable for the Magento user/webuser.

83

This error message is also shown if your app/etc/config.php is missing. If app/etc/env.php is present and you are still seeing this issue, check for app/etc/config.php. If it is not present, Magento can create it by running bin/magento module:enable --all. This will recreate the file. Then, try running bin/magento setup:upgrade again.

4
  • 5
    In my case this was the issue, app/etc/env.php was present but app/etc/config.php was not.
    – Niels
    Oct 4, 2018 at 8:49
  • I have both app/etc/env.php and app/etc/config.php still having this error..
    – Ajwad Syed
    Apr 15, 2019 at 11:04
  • perfect answer!!! made my day +1 :) Sep 3, 2019 at 9:11
  • This answer help me. Thanks.
    – Ali Raza
    Aug 4, 2021 at 14:12
4

In my case, I am using Magento 2 by docker,

I had both app/etc/env.php and app/etc/config.php files. Also had .htaccess file in root folder and still had this error while running any command of magento:

Invalid configuration file: '/var/www/html/app/etc/env.php'

Then,

  1. I killed all running containers with: docker kill $(docker ps -q)
  2. Deleted all stopped containers with: docker rm $(docker ps -a -q)
  3. Deleted all images with: docker rmi $(docker images -q)
  4. Removed all unused volumes with: docker volume prune

4th point is must.

And installed Docker Image for Magento 2 again. This worked for me.

3

First you need to deploy your website.The first Check all folder in the .htaccess file is available after

php bin/magento setup:upgrade

and

php bin/magento setup:static-content:deploy

or pub > static file checked not static folder so create static folder and index.php in Pub file. index.php not available so please copy your other project and paste

0

Also check if your cache_dir is writable. I advise you to check your logfiles.

2
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review May 14, 2020 at 15:13
  • @ManashviBirla, this is an answer. I had the same exact problem and it was because of the cache_dir not being writable...
    – Black
    May 14, 2020 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.