Composer在Windows 10上安装laravel/installer出错。

3

我正在使用Windows 10和Composer。当我尝试安装Laravel安装程序时,出现了错误。非常感谢您提供任何帮助。以下是在我尝试安装时的完整输出:

$ composer global require laravel/installer
Changed current directory to C:/Users/rudy/AppData/Roaming/Composer
Using version ^4.1 for laravel/installer
./composer.json has been created
Running composer update laravel/installer
Loading composer repositories with package information
Updating dependencies
Lock file operations: 12 installs, 0 updates, 0 removals
  - Locking laravel/installer (v4.1.0)
  - Locking psr/container (1.0.0)
  - Locking symfony/console (v5.1.8)
  - Locking symfony/polyfill-ctype (v1.20.0)
  - Locking symfony/polyfill-intl-grapheme (v1.20.0)
  - Locking symfony/polyfill-intl-normalizer (v1.20.0)
  - Locking symfony/polyfill-mbstring (v1.20.0)
  - Locking symfony/polyfill-php73 (v1.20.0)
  - Locking symfony/polyfill-php80 (v1.20.0)
  - Locking symfony/process (v5.1.8)
  - Locking symfony/service-contracts (v2.2.0)
  - Locking symfony/string (v5.1.8)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 12 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-php80 (v1.20.0): Extracting archive
  - Installing symfony/process (v5.1.8): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.20.0): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.20.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.20.0): Extracting archive
  - Installing symfony/polyfill-ctype (v1.20.0): Extracting archive
  - Installing symfony/string (v5.1.8): Extracting archive
  - Installing psr/container (1.0.0): Extracting archive
  - Installing symfony/service-contracts (v2.2.0): Extracting archive
  - Installing symfony/polyfill-php73 (v1.20.0): Extracting archive
  - Installing symfony/console (v5.1.8): Extracting archive
  - Installing laravel/installer (v4.1.0): Extracting archive
    Skipped installation of bin bin/laravel for package laravel/installer: name conflicts with an existing file
6 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files

Installation failed, deleting ./composer.json.


  [RuntimeException]
  Could not scan for classes inside "C:\Users\rudy\AppData\Roaming\Composer\vendor/symfony/polyfill-php73/Resources/s
  tubs" which does not appear to be a file nor a folder


require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-scripts] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>]...
6个回答

3

您遇到了与symfony/polyfill相关的问题
手动删除vendor和composer.lock

或者
清理composer缓存对我有用:

composer clearcache

然后安装您的软件包


感谢您的回复。不幸的是,这些方法都对我无效。所以我尝试第n次安装Composer.exe,然后运行laravel/installer,这次成功了。 - TopAngler
不用谢,因为如果有插件错误,composer.exe会卡住。所以在你运行任何东西之后,请习惯于使用 php artisan cache:clearphp artisan config:clear 然后再运行 composer clearcache - Adhitya

3

当你的本地环境中的文件损坏时,通常会发生这种情况。尝试清除缓存并重新安装软件包。

$ composer clearcache
$ composer global require laravel/installer

非常感谢您的快速回复,但那并没有起作用。清除缓存后仍然出现相同的错误。 - TopAngler

0
你可以尝试下载并安装composer.exe。

这可能更适合作为评论而不是问题的答案。 - marcogmonteiro
发表评论需要50个声望值。 - Rahul Gupta

0
在发布这篇文章之前,我重新安装了4次Composer。在尝试上述解决方案无果后,我又尝试重新安装Composer,然后运行了laravel/installer - 一切都正常工作了。感谢所有抽出时间回复的人。

0

清除缓存对我也起作用了。 以下是我的操作步骤:

  1. composer clearcache
  2. composer global require laravel/installer 然后安装成功了

0
对我来说,问题出在7zip上。 Composer使用了来自Lua的7z.exe(我之前安装过)。 当我从官方网站安装了7z并更新了PATH变量后,这个错误就解决了。
虽然我无法提供解释,但我不确定发生了什么……

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接