升級至Adobe Commerce 2.4.4時出現的Composer外掛程式問題

本文提供解決方案,可避免從Adobe Commerce 2.4.3和更早版本升級至Adobe Commerce 2.4.4或更新版本時(已發行未來版本時),撰寫器外掛程式發生問題。

說明 description

環境

  • Adobe Commerce內部部署,更新至2.4.4或更新版本時的任何版本(發行時)
  • 雲端基礎結構上的Adobe Commerce,更新至2.4.4或更新版本時的任何版本(發行時)
  • Magento Open Source,更新至2.4.4或更新版本時的任何版本(發行時)

問題/症狀

2022年7月之後更新至Adobe Commerce 2.4.4或更新版本時,您可能會收到撰寫器有關外掛程式的警告。

要再現的步驟

先決條件: 已安裝Adobe Commerce 2.4.3或更舊版本。

  1. 開始升級,如執行升級中所述。
  2. 執行撰寫器更新命令以升級Adobe Commerce應用程式。

預期結果

升級成功。

實際結果

安裝失敗,並出現類似下列的錯誤:

Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 591 installs, 0 updates, 0 removals
  - Installing laminas/laminas-dependency-plugin (2.2.0): Extracting archive
laminas/laminas-dependency-plugin contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
Do you trust "laminas/laminas-dependency-plugin" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [ y,n,d,?]  y
Plugin initialization failed (require(app/etc/NonComposerComponentRegistration.php): failed to open stream: No such file or directory), uninstalling plugin
  - Removing laminas/laminas-dependency-plugin (2.2.0)
    Install of laminas/laminas-dependency-plugin failed
[ ErrorException]
  require(app/etc/NonComposerComponentRegistration.php): failed to open stream: No such file or directory

原因

2022年7月後,Composer將allow-plugins選項的預設值變更為{},除非允許,否則將不會再載入外掛程式。

解決方法 resolution

根據您安裝Adobe Commerce的方式,將下列專案新增至您的composer.json檔案:

  • 如果已使用composer create-project命令🔗建立專案:
"config": {
    "allow-plugins": {
        "dealerdirect/phpcodesniffer-composer-installer": true,
        "laminas/laminas-dependency-plugin": true,
        "magento/*": true
    }
}
  • 如果專案是以其他方式建立的,而且沒有dealerdirect/phpcodesniffer-installer" in "require-dev區段:
"config": {    "allow-plugins": {        "laminas/laminas-dependency-plugin": true,        "magento/*": true    }}

更新composer.json檔案之後,請執行composer update命令並重新啟動升級程式。

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f