laravel Composer 安装无法删除文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41626781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:06:47  来源:igfitidea点击:

Composer install cannot delete files

laravelcomposer-phplaravel-forge

提问by user3691644

I am attempting to run a composer install to update dependencies on my production server, but I continue to get the following error (this happens to be on a Laravel Forge deployed server).

我正在尝试运行 composer install 来更新我的生产服务器上的依赖项,但我继续收到以下错误(这恰好是在 Laravel Forge 部署的服务器上)。

Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 0 installs, 0 updates, 24 removals
  - Removing symfony/dom-crawler (v3.2.1)

[RuntimeException]
Could not delete /home/forge/website.com/vendor/symfony/dom-crawler/composer.json:

Why is this happening? Can I manually delete the entire vendor folder on the forge server and redeploy all the dependencies without harming it?

为什么会这样?我可以手动删除伪造服务器上的整个供应商文件夹并重新部署所有依赖项而不损害它吗?

回答by Gayan Kavirathne

The problem might be because composer is hitting its timeout. So you might be need increase the time out of composer.

问题可能是因为作曲家超时了。所以你可能需要增加作曲家的时间。

You could take the following measures to gain some speed:

您可以采取以下措施来提高速度:

  1. Increase composer process-timeout (default 300) (not really needed if the following settings will help you gain speed, but can't hurt)
  2. Set dist as preferred install type.
  3. Enable https protocol for github, which is faster.

    ~/.composer/config.json
         {
          "config": {
                    "process-timeout":      600,
                    "preferred-install":    "dist",
                    "github-protocols":     ["https"]
                     }
                  }
    
  1. 增加 composer process-timeout(默认 300)(如果以下设置可以帮助您提高速度,则不需要,但不会受到伤害)
  2. 将 dist 设置为首选安装类型。
  3. 为github启用https协议,速度更快。

    ~/.composer/config.json
         {
          "config": {
                    "process-timeout":      600,
                    "preferred-install":    "dist",
                    "github-protocols":     ["https"]
                     }
                  }
    

If you still have problems after that, you can also clear composer's cache:

如果之后还是有问题,你也可以清除composer的缓存:

 rm -rf ~/.composer/cache

Also you might try updating git.

您也可以尝试更新 git。

Similar question is discussed Here in laracasts

在 laracasts 中讨论了类似的问题

回答by Shi

It might be a permission problem. Maybe at some point you used sudoand the files now are owned by root. If you usually use another user for this operation and now use that one again, the files of course cannot be removed.

可能是权限问题。也许在某些时候您使用过sudo并且文件现在归root. 如果您通常使用另一个用户进行此操作,现在再次使用该用户,则当然无法删除文件。

So try

所以试试

ls -l /home/forge/website.com/vendor/symfony/dom-crawler/composer.json

to see which user/group owns the file. Also check the permissions of that directory; maybe it is not writeable anymore?

查看哪个用户/组拥有该文件。还要检查该目录的权限;也许它不再可写了?