Private composer packages - no valid composer.json was found

孤人 提交于 2019-11-30 11:45:12

You must not include a version specification in your library's composer.json if it is actually managed by a supported source control system. Currently you are saying that your master branch IS version 0.3 (which is a stable version), but you are trying to include "dev-master" (which is an unstable version). Composer might get confused if that software really is "dev-master" or "version 0.3".

If you actually are developing new releases for the 0.3.x series in your master branch, you should define a branch alias instead. Add this to your current development branch for versions 0.3.x:

"extra": {
    "branch-alias": {
        "dev-master": "0.3.x-dev"
    }
}

If you want to move on to version 0.4 or 1.0, you'd branch at the "last" state of the 0.3 series with a branch named "0.3.x" and then update the composer.json in the master branch to point dev-master to a new alias (like "dev-master": "0.4.x-dev"). You could also name your old 0.3 branch anyway you like and then add an alias for THAT branch.

Doing this will enable you to require the latest development version of 0.3.x like this:

"require": {
    "my-vendor/my-package": "0.3.*@dev"
}

This will pull the latest 0.3 version - which currently would be the latest commit in the master branch because of the defined alias.

The way you are currently set up forces you to explicitly include version 0.3, which is a moving target without making that fact explicitly known.

Giving an explicit version tag should only be done if there is no version control system available that is able to give Composer the version number, i.e. there are no tags available, or the tags do not comply with Composer's requirement for version numbers. Since you seem to be in control of that vcs, it probably is a good idea to make the tags conform to Composers standard instead of making it troublesome to release a new version.

After you fixed this, I do expect your installation to NOT require that package.json file anymore, because that file now repairs the trouble you created with that version declaration. You'd then also not need that composer reference anymore, but can revert back to mentioning the original repository like you did.

If you feel you are using too many private repositories which are all requiring more private repositories, and are sick of mentioning them all in a long list, you could think about using Satis to create such a list of found packages instead of manually creating them.

I had the same error, after deleting folders from vcs everything works fine

sudo rm -R ~/.composer/cache/vcs/*

On Windows (as @Serbu suggested):

Clearing the vcs, repo and files directories under C:\Users\Me\AppData\Local\Composer\

James

I've managed to get it working by referencing a package.json over HTTP:

"repositories": [
    {
        "type": "composer",
        "url": "http://localhost/packages.json"
    }
]

so the packages.json file looks like:

{
    "packages": {
        "vendor/my-package": {
            "dev-master": {
                "name": "vendor/my-package",
                "version": "dev-master",
                "source": {
                    "url": [repository URL],
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    }
}

Also, its seems an autorun registry entry I had for command prompt was interfering with composer running.

See: Requiring a private git Bitbucket repository fails to find valid composer.json.

I know this is a bit old, but for some that might encounter this issue, this is how it works for me.

Clear the composer cache.

composer clearcache

Rerun the satis build script.

I've just updated composer.json to last version and the problem gone away.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!