Such errors can appear if the module you're trying to install or update is already present in Magento installation under some other path. In other words, there's a duplicate with the exact same files, but it is located in another directory. Essentially, to resolve the error, it is necessary to remove one of the packages. Depending on what caused the error, there are two solutions:
1. Duplicates from direct file upload.
When installing or updating Amasty modules for Magento, there are two primary methods to choose from: using composer or direct file upload. Depending on the initial installation method, the module files will be located in a specific directory. Each installation method has its own writing directory:
- Modules installed via composer are placed in the vendor/ directory.
- Modules installed manually through file upload, are placed in the app/code/ directory.
If a module was first installed via file upload and then reinstalled or updated via composer (or vice versa), this can lead to duplicate module installations in both the app/code/ and vendor/ directories. As a result, you might face a similar error while running setup scripts:
This error indicates that the module exists in both the app/code/ and vendor/ directories simultaneously, which prevents Magento from deploying correctly.
To resolve this, remove the module files from the app/code/ directory if they also exist in the vendor/ directory. The module configuration is stored in the DB, so the data will be preserved. Ensure you back up your Magento installation before deleting any files, especially if you have made customizations or fixes to the module files in app/code/.
As the option of manual module upload has been deprecated at our website, and composer remains the only source of extension packages now, we strongly recommend switching to this installation method for our modules in general. Using composer, you will be able to easily and efficiently manage all package versions and dependencies. Our guide on switching installation methods is available here: How to move manually installed extension to Composer?
2. Duplicates from Adobe Marketplace repository.
This situation can happen if you previously purchased our extension at Adobe Marketplace, installed it from Magento repository repo.magento.com, and then attempted to install the same module from our repository composer.amasty.com. The same extension package can have slightly different names in these two repositories. For example, here's how Amasty_GdprCookie module is called in different repositories:
- composer.amasty.com - amasty/gdpr-cookie;
- repo.magento.com - amasty/gdpr-cookie-sys.
As a result, there might be two module packages in the vendor/ directory: with different names, but identical contents. It will lead to the same autoload error mentioned above:
Autoload error: Module 'Amasty_GdprCookie' from 'vendor/amasty/gdpr-cookie' has already been defined in 'vendor/amasty/gdpr-cookie-sys'
The solution would be to ignore Adobe Marketplace repository, so that composer would download Amasty extension only from one source. For that, edit your composer.json file and insert the following line in the section with repo.magento.com repository: