Can't get composer “path” repository to work

浪尽此生 提交于 2019-12-03 22:12:40

I posted the issue on Github as well and it turns out that the documentation is a little misleading. It says:

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/my-package"
        }
    ],
    "require": {
        "my/package": "*"
    }
}

However, if you just have a local repo without releases, you have to use:

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/my-package"
        }
    ],
    "require": {
        "my/package": "dev-master"
    }
}

The version dev-master is the key here (given that you are working on the master branch). This was mildly infuriating, but thanks to some helpful composer contributors, I could finally get a grip on this.

I hope this may help somebody in the future.

Good luck!

What worked for me was very similar to the above, but I had to specifically target the branch I was developing on.

Assuming code in directory /newapp on the same level as /app, and a branch named feature/the-new-package:

"repositories": [
  {
    "type": "path",
    "url": "newapp"
  }
],
"require": {
  "package/newapp": "dev-feature/the-new-package"
},

\* did not work, neither did dev-master. It had to be dev-feature/the-new-package.

For future Googlers, add your version to the composer.json and then require the package with the --prefer-source option.

For example: composer require your-vendor/package:1.0.* --prefer-source

What helped me resolve was composer clear-cache and then running composer update.

Explanation: I had initially tried to composer install my/package which failed on dependency versions. So I needed to make some local modifications to make it work with Laravel 6.0. However, it continued checking for the wrong version of Laravel packages which led me to believe it was not seeing my local repository which I set in the repositories key with "type": "path". I first ensured the path existed and I was on the correct branch (master which is why I use dev-master in my composer.json). Once I cleared the composer cache and ran the update it updated using my local path with no dependency issues.

"repositories": [
    {
        "type": "path",
        "url": "../libs/package-name"
    }
],
"require-dev": {
    "pkg-maintainer/package-name": "dev-master"
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!