composer无法下载tp5.1的核心框架:Failed to extract topthink/framework

问题:

在项目目录下执行

 % composer update topthink/framework

1.执行上面的命令下载tp5.1的核心框架think php,报错无法下载,保存,无法解压下载的临时文件

Failed to extract topthink/framework: (9) unzip -qq ‘/Users/liangyuji/Desktop/workspace/www/layuji/vendor/composer/tmp-2aed41abee1ebb45f997bb9298058753’ -d ‘/Users/liangyuji/Desktop/workspace/www/layuji/vendor/composer/45fda960’

unzip: cannot find or open /Users/liangyuji/Desktop/workspace/www/layuji/vendor/composer/tmp-2aed41abee1ebb45f997bb9298058753.

  1. 难道是打开的方式不对?换个姿势看看
% composer require topthink/think-installer
    Failed to extract topthink/framework: (9) unzip -qq  '/Users/liangyuji/Desktop/workspace/www/layuji/vendor/composer/tmp-d7b9c1894bc64bc0bfc97e4456d5f78b' -d '/Users/liangyuji/Desktop/workspace/www/layuji/vendor/composer/44c44b00'

unzip:  cannot find or open /Users/liangyuji/Desktop/workspace/www/layuji/vendor/composer/tmp-d7b9c1894bc64bc0bfc97e4456d5f78b.

    This most likely is due to a custom installer plugin not handling the returned Promise from the downloader
    See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix
Generating autoload files

还是报错!!!

有个提示⚠️:

This most likely is due to a custom installer plugin not handling the returned Promise from the downloader
See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix
大部分这种情况是由于插件问题导致无法下载,可以查看https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb的列子进行修复

方案

更换composer的镜像为阿里的镜像

注意:最近phpcomposer镜像存在问题,可以改成
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

更换镜像源是否可行,但还是一样。

按上面的提示进行修复,查看网址案例:

1.第一个回复是说使用1.x x x 的版本即可

use version 1.xxx is ok.
使用1.xxx版本可以。

查看自己的版本,为2.0的版本

liangyuji@liangyujideMacBook-Pro layuji % composer -v
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.0.7 2020-11-13 17:31:06

2.第二个回复是说插件不兼容

This is due to a custom installer plugin interacting badly with Composer 2.
这是因为自定义安装程序插件与Composer 2交互不良。

这时可以看一下是项目目录的哪个插件问题

unzip: cannot find or open /Users/liangyuji/Desktop/workspace/www/layuji/vendor/composer/tmp-d7b9c1894bc64bc0bfc97e4456d5f78b.
无法解压vendor/composer/下的文件

composer无法下载tp5.1的核心框架:Failed to extract topthink/framework_第1张图片
将该composer的文件夹目录删除,重新执行下载命令,即可

liangyuji@liangyujideMacBook-Pro layuji % composer update topthink/framework       
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
  - Downloading topthink/framework (v5.1.41)
  - Installing topthink/think-installer (v2.0.5): Extracting archive
  - Installing nowakowskir/php-jwt (2.0.1): Extracting archive
  - Installing topthink/framework (v5.1.41): Extracting archive
Generating autoload files

可以看到执行后回重新下载composer目录并安装thinkphp成功。

你可能感兴趣的:(php,php)