4

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?

Rafael Corrêa Gomes
  • 13,309
  • 14
  • 84
  • 171
DarthVegan
  • 717
  • 8
  • 18
  • 32
  • 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 Jan 03 '17 at 21:05

2 Answers2

5

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.

Rafael Corrêa Gomes
  • 13,309
  • 14
  • 84
  • 171
  • 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 Feb 07 '17 at 21:26
  • Followed the steps and it worked. Just upgraded to 2.2 from 2.1.9. :D Thanks! – jehzlau Sep 28 '17 at 13:21
  • So far rm -rf vendor/composer is the only thing that does the trick for me. – tylersDisplayName Mar 29 '19 at 16:58
2

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.

Aaron Allen
  • 9,009
  • 2
  • 26
  • 36