私人composer包 - 没有找到有效的composer.json [英] Private composer packages - no valid composer.json was found

查看:2400
本文介绍了私人composer包 - 没有找到有效的composer.json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试加载我使用composer托管在BitBucket的库,如在官方文档此处,但仍会收到以下错误:

  [Composer\Repository\InvalidRepositoryException] 
在任何分支或标签中找不到有效的composer.json存储库URL],无法从中加载包。

这是我的项目 composer.json:

  {
name:项目名称,
require:{
my-vendor / my-package:dev-master
},
repositories:[
{
type:vcs,
url: [repository URL]
}
]
}

是我的远程存储库中的composer.json(显然找不到):

  {
name :my-vendor / my-package,
version:0.3,
autoload:{
psr-0:{
NS_ :src
}
}
}

应该提到两个composer.json文件都在根目录中,因为它们应该是。



其他一些注意事项:



我也试过了非composer包方法,我在我的项目composer.json中指定包信息,并从我的远程仓库中省略composer.json,如文档。这成功克隆主分支,但会导致以下错误:

  [RuntimeException] 
无法执行git checkout master&& git reset --hardmaster

fatal:不是一个git仓库(或任何父目录):.git

但是,该软件包是按照预期下载到/ vendor的,所以我不知道为什么它试图再次检出master。



这不是我想解决这个问题的方式(因为我宁愿使用远程仓库中的composer.json),但它可能有助于在其他地方识别一个问题。



感谢任何帮助。



EDIT 我设法通过HTTP引用一个package.json工作:

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

packages.json如下所示:

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

这是唯一的办法吗?如果我只使用一个或两个内部包,似乎有点过分的主机我自己的packages.json文件。



无论如何,这是给



强制执行一个错误(无效的SSH密码)给出:

  [RuntimeException] 
无法执行git clone ]C:\workspace\DFv3\vendor\vendor/my-package&& cd / DC:\workspace\DFv3\vendor\vendor/my-package&&& git remote add composer[repository URL]&& git fetch composer

所以我可以清楚地看到它在做什么。但是,之后,此命令会将 cd 运行到 .git 尝试运行:

  git checkoutmaster& git reset --hardmaster

大概要摆脱它拉出的作曲家实例。但是,它运行在错误的目录,我不知道为什么..

解决方案

只是想标记为回答这里。看起来像一个自动运行的注册表项我有命令提示符干扰作曲家运行。



更多在这里:



a href =https://github.com/composer/composer/issues/2418 =nofollow> https://github.com/composer/composer/issues/2418


I'm trying to load a library I have hosted on BitBucket using composer as explained both in the official documentation and here, but keep receiving the following error:

[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of [repository URL], could not load a package from it.

Here is my project composer.json:

{
    "name": "Project name",
    "require": {
        "my-vendor/my-package": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": [repository URL]
        }
    ]
}

And here is the composer.json in my remote repository (that apparently can't be found):

{
    "name": "my-vendor/my-package",
    "version": "0.3",
    "autoload": {
        "psr-0": {
            "NS_": "src"
        }
    }
}

I should mention that both composer.json files are in the root directory as they should be.

Some other things to note:

I've also tried the "non-composer package" approach, whereby I specify the package information in my project composer.json, and omit the composer.json from my remote repository, as outlined in the documentation. This successfully clones the master branch but then results in the following error:

[RuntimeException]
Failed to execute git checkout "master" && git reset --hard "master"

fatal: Not a git repository (or any of the parent directories): .git

However, the package is downloaded to /vendor as expected, so I'm not sure why it's trying to checkout master again.

This is not the way I wish to solve this problem (as I'd rather make use of a composer.json in the remote repository), but it might help identify an issue elsewhere.

Thanks for any help.

EDIT

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

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

The packages.json looks like:

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

Is this the only way to get this working? It seems a bit overkill to host my own packages.json file if I'm only going to be using one or two in-house packages.

Regardless, this is giving me the same Git error as I mentioned previously.

EDIT 2

Forcing an error (invalid SSH passphrase) gives this:

[RuntimeException]
Failed to execute git clone "[repository URL]" "C:\workspace\DFv3\vendor\vendor/my-package" && cd /D "C:\workspace\DFv3\vendor\vendor/my-package" && git remote add composer "[repository URL]" && git fetch composer

So I can clearly see what it's doing here. However, it seems after this command runs it cds into the .git directory and tries running:

git checkout "master" && git reset --hard "master"

Presumably to get rid of the composer instance it pulled. However, it's running this in the wrong directory and I can't figure out why..

解决方案

Just want to mark this as answered here. Seems an autorun registry entry I had for command prompt was interfering with composer running.

More here:

https://github.com/composer/composer/issues/2418

这篇关于私人composer包 - 没有找到有效的composer.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆