0
votes

I have a project which requires a bunch of local path repositories. Those local path repositories partly require each other and also remote repositories.

For example one of the local repo composer.json looks like this:

{
    "description": "",
    "type": "neos-project",
    "name": "mapo/campaign",
    "repositories": [
        {
            "type": "path",
            "url": "Source/Mapo.NodeTypes"
        }
    ],
    "require": {
        "mapo/nodetypes": "*"
    },
    "autoload": {
        "psr-4": {
            "Mapo\\Campaign\\": "Classes/"
        }
    },
    "extra": {
        "neos": {
            "package-key": "Mapo.Campaign"
        }
    }
}

The mapo/nodetypes local package then requires also a private remote repository:

{
    "description": "",
    "type": "neos-project",
    "name": "mapo/nodetypes",
    "minimum-stability": "dev",
    "repositories": [
        {
            "type": "git",
            "url": "url to private repo.git"
        },
        {
            "type": "path",
            "url": "../Mapo.Somepackage"
        },
    ],
    "require": {
        "mapo/privateproject": "*",
        "mapo/somepackage": "@dev"
    },
    "autoload": {
        "psr-4": {
            "Mapo\\NodeTypes\\": "Classes/"
        }
    },
    "extra": {
        "neos": {
            "package-key": "Mapo.NodeTypes"
        }
    }
}

Now I need to test a new feature in mapo/privateproject. So I created a new branch in the private repo called issue0815 and made my changes. I also created a new branch issue0815 in the main mapo project (which has the local path composer.json changes locally).

I updated the dependency of mapo/nodetypes to "mapo/privateproject": "dev-issue0815",.

My problem is that, no matter which command, composer refuses to install the issue0815 branch for the private repository. At first composer complained, that it cannot install the dependency dev-issue0815 because the composer.lock prevented it. So I removed all usages of the private repo and the mapo/nodetypes from my composer.lock.

What surprised me the most, was that composer recovered the original composer.lock file. It just completely ignored my current local main project branch - which has the modification for the local path repo composer.json files and just required the contents from the master branches.

So, how can I update a dependency of a local path repo which needs a specific branch from a private repo?

1
When you say that "composer.lock prevented it", did you do a composer install or composer update? And how exactly did it "prevent" it? Did you get an error message? If yes, please share that as well.Magnus Eriksson
Please post output of composer updateManzolo

1 Answers

1
votes

This one took me quite a while, but the reason why my changes to composer.json have been completely ignored including also when I deleted the composer.lock was that, composer ignores your changes if it concludes, that the packages from vendor/composer/installed.json are correct.

From https://github.com/composer/composer/issues/4312#issuecomment-191488570:

Right now Composer prefers installed packages, derived from the installed.json file. So as long as the replacement is valid, it will indeed keep generating the same solution and thus lock. This is just because that's how Composer works internally.

To 'reset' it completely and make it rethink its installed packages (before it automatically 'corrects' because of package updates) you'd have to remove vendor/composer/installed.json as well as the lock. This will trigger a complete reevaluation of dependencies and reinstall. You could also just go for the full cleanup then and delete the entire vendor directory.

Thats also the reason why it is often suggested to remove the vendor directory, I think.