I'm getting this error after I ran the setup:upgrade command and this was after the upgrade to Magento 2.1.3

Module 'Magento_CatalogInventory' from '/var/www/vhosts/website/httpdocs/app/code/Magento/CatalogInventory' has been already defined in '/var/www/vhosts/website/httpdocs/vendor/magento/module-catalog-inventory'.

How do I fix this error?

  • 1
    Did you clear the var directories rm -rf var/cache var/generation var/page_cache and also do you have a duplicate copy of Magento_CatalogInventory module in your app/code directory?
    – Loxzibit
    Commented Jan 3, 2017 at 21:05

2 Answers 2


You cloned your Magento from Github, so all your core is in folder app/code/Magento/, you need remove it and run the composer command to have your core in the folder vendor/.

Note that you shouldn't clone the repository, next time install using Composer.

These are the steps that I used to fix:

rm -rf var/view_preprocessed/ var/cache/ var/page_cache/ var/di/ var/tmp/ var/generation/ pub/static/frontend/ app/code/Magento/ vendor/magento composer.lock

chmod 777 -R *

composer update -vvvv

php -f bin/magento setup:static-content:deploy

find . -type d -exec chmod 775 {}

find . -type f -exec chmod 660 {}

chmod u+x bin/magento

bin/magento maintenance:disable

bin/magento cache:clean

The Composer command will install de vendor modules.

  • This works as you deleted the contents of app/code/ using app/code/*. If you happen to have any other extension you installed manually these will be lost in this deletion. You need only delete "/var/www/vhosts/website/httpdocs/app/code/Magento/CatalogInventor/". The likely hood is you have installed CatalogInventor inventory using composer and so you have the same extension twice (or maybe different versions).
    – Flipmedia
    Commented Feb 7, 2017 at 21:26
  • Followed the steps and it worked. Just upgraded to 2.2 from 2.1.9. :D Thanks!
    – jehzlau
    Commented Sep 28, 2017 at 13:21
  • So far rm -rf vendor/composer is the only thing that does the trick for me. Commented Mar 29, 2019 at 16:58

It looks like you installed Magento by cloning the github repository and then tried to upgrade using composer. The problem is that composer places the core modules in the Vendor directory while cloning the repository results in them being in App/Code directory, so now you have duplicates. You should remove the App/Code/Magento directory to solve the error. Note that you shouldn't clone the repository, next time install with composer.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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