git 作曲家更新不拉最新的开发大师

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22608398/
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-19 09:53:08  来源:igfitidea点击:

composer update not pulling latest dev-master

gitcomposer-php

提问by josef.van.niekerk

I've created two git repositories that we need to install in one of our web applications by using PHP's composer. There are two branches on each repository, masterand dev-master.

我创建了两个 git 存储库,我们需要使用 PHP 的composer将它们安装在我们的一个 Web 应用程序中。每个存储库上有两个分支,masterdev-master

Inside the project I want the package to install, I've created the following composer.json package configuration:

在我想要安装包的项目中,我创建了以下 composer.json 包配置:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "proprietary",
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "impression-works/pdf-generator",
                "version": "dev-master",
                "source": {
                    "url": "[email protected]:...",
                    "type": "git",
                    "reference": "dev-master"
                }
            }
        },
        {
            "type": "package",
            "package": {
                "name": "impression-works/psd-templates",
                "version": "dev-master",
                "source": {
                    "url": "[email protected]:...",
                    "type": "git",
                    "reference": "dev-master"
                }
            }
        }
    ],
    "require": {
        // ...
        "impression-works/psd-templates": "dev-master",
        "impression-works/pdf-generator": "dev-master"
    },
    "autoload": {
        // ...
        "psr-0": {
            "ImpressionWorks\PsdTemplates": "vendor/impression-works/psd-templates/src",
            "ImpressionWorks\PdfGenerator": "vendor/impression-works/pdf-generator/src"
        }
    },
    // ...
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
}

When I initially run composer update or composer install, the impression-works packages install perfectly, however, if I make changes to these repositories, and push them to dev-master, any successive calls to composer update simply reports:

当我最初运行 composer update 或 composer install 时,impress-works 软件包安装得很好,但是,如果我对这些存储库进行更改,并将它们推送到 dev-master,任何对 composer update 的连续调用只会报告:

Nothing to install or update

How do I force composer to update to the latest commit on these two custom packages of ours?

我如何强制 composer 更新到我们这两个自定义包的最新提交?

回答by Christian

I come to this page multiple times a week from a Google search, only to see that it doesn't answer my problem. So here goes.

我每周通过 Google 搜索多次访问此页面,却发现它没有解决我的问题。所以就到这里了。

I'm using packagist.org, not VCS. I do not want to use VCS as it slows Composer even more, and it's already painfully slow.

我使用的是 packagist.org,而不是 VCS。我不想使用 VCS,因为它会进一步降低 Composer 的速度,而且它已经非常缓慢了。

Condider the following scenario. Application in early development depends on a package I'm building. The package is also early in dev, so dev-master as version to get the latest master every time.

考虑以下场景。早期开发中的应用取决于我正在构建的包。这个包也是在dev的早期,所以dev-master作为版本,每次都能拿到最新的master。

I fix a critical bug in the package, commit & push it, mash the update button in packagist.org, and then run composer update, and absolutely nothing happens.

我修复了包中的一个关键错误,提交并推送它,在 packagist.org 中混搭更新按钮,然后运行composer update,绝对没有任何反应。

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files

At this point you might try clearing the cache. It doesn't help.

此时您可以尝试清除缓存。它没有帮助。

Some point in time you'll stumble upon this open issue from 2012. After that you'll find out that the only way to get the latest version installed is to use the commit hash in the require.

在某个时间点,您会偶然发现这个 2012 年的未解决问题。之后,您会发现安装最新版本的唯一方法是使用 require 中的提交哈希。



composer require vendor/package dev-master#0d7d6c88

composer require vendor/package dev-master#0d7d6c88

This requires that you manually get the commit hash and update the version to composer.json, and then run composer updateagain. Not exactly what you'd expect from a dependency manager. Looks like the issue is never going away, so unless someone writes a better Composer, we're stuck with this behavior.

这需要您手动获取提交哈希并将版本更新为composer.json,然后composer update再次运行。不完全是您对依赖项管理器的期望。看起来这个问题永远不会消失,所以除非有人写出更好的 Composer,否则我们会坚持这种行为。

The alternative is tagging every single commit that you want to download using Composer. Beware of confusing minimum stability rules & errors, which Composer throws by default.

另一种方法是使用 Composer 标记您要下载的每个提交。谨防混淆的最低稳定性规则和错误,这是 Composer 默认抛出的。

回答by Seldaek

You should rather use custom repositories of type VCS. The package repo you used has a few limitations as highlighted in the docs:

您应该使用VCS类型的自定义存储库。您使用的包 repo 有一些限制,如文档中突出显示的

  • Composer will not update the package unless you change the version field.
  • Composer will not update the commit references, so if you use master as reference you will have to delete the package to force an update, and will have to deal with an unstable lock file.
  • 除非您更改版本字段,否则 Composer 不会更新包。
  • Composer 不会更新提交引用,因此如果您使用 master 作为引用,则必须删除包以强制更新,并且必须处理不稳定的锁定文件。

回答by J?rg Kütemeier

I just have had the same problem. After figuring it out, the solution is fairly simple: clean the cache.

我只是遇到了同样的问题。弄清楚之后,解决方案相当简单:清理缓存。

What Josef and Christian are looking for can be accomplished with this two lines:

Josef 和 Christian 正在寻找的东西可以通过以下两行来完成:

composer clearcache
composer upgrade

That loads the last repository master for me. Hope it helps the next one, reading this thread.

这为我加载了最后一个存储库主。希望它有助于下一个,阅读这个线程。

Important Note:

重要的提示:

You have to wait for the GitHub service hook to kick in and update the composer package on packagist.org or use the 'Update' button manually on the site.

您必须等待 GitHub 服务挂钩启动并更新 packagist.org 上的 composer 包,或者手动使用站点上的“更新”按钮。

This is not a matter of seconds... you have to wait for some time (normally one to five minutes) to give packagist a chance to distribute the changes.

这不是几秒钟的事情……您必须等待一段时间(通常为一到五分钟)才能让 packagist 有机会分发更改。

So for constant, rapid development, I would just manually cd vendor/base/packageand git update. And from time to time try the above clearcacheand upgrade.

所以为了持续、快速的开发,我只会手动cd vendor/base/packagegit update. 并不时尝试上述clearcacheupgrade

回答by Magentron

A simpler version than the answer of @Bitclaw, for me the following works flawlessly:

@Bitclaw的答案更简单的版本,对我来说,以下内容完美无缺:

composer update --prefer-source developer/package

回答by Imran Zahoor

Try this

尝试这个

composer clear-cache composer update

composer clear-cache composer update

回答by Bitclaw

Running composer upgrade is a bit dangerous since it may update all the other dependencies you have. In this case I would run the following:

运行 composer upgrade 有点危险,因为它可能会更新您拥有的所有其他依赖项。在这种情况下,我将运行以下命令:

composer clearcache;composer update --lock;composer install --prefer-source -vvv