Saifur Rahman Mohsin
Saifur Rahman Mohsin

Reputation: 1011

Why is repository local directive in composer not working?

There is a project "OctoberCMS" that has a library called "rain" viz. a dependency. I cloned them to my desktop using:

git clone --branch develop [email protected]:octobercms/october.git
git clone --branch develop [email protected]: octobercms/library.git

(Actually cloned forked versions but anyway showing the original repo URLs above) So the thing is that I want to make changes and a PR to the library project. So I opened the composer.json inside october folder and then added:

"repositories": [
    {
        "type": "path",
        "url": "../library",
        "options": {
            "symlink": true
        }
    }
],

And since the main OctoberCMS project already has october/rain viz the library project as a dependency declared in it's composer, I changed the code from "october/rain": "1.1.*", to "october/rain": "@dev",, hoping that it will symlink and load the local repo. But it didn't work.

I figured that the other dependencies of OctoberCMS i.e. system, backend and cms also require `"october/rain": "1.1.*" and perhaps that is why composer loads the packagist version over my local clone. So instead, I tried using the replace directive, since I read that it helps to tell dependencies to ignore whatever is in the block as it's satisfied,

"replace" : {
    "october/rain": "~1.1.0"
},

hoping that composer will think that this is satisfied by the main project's composer directive with @dev but that didn't work either. When I finally removed the 3 requires i.e.:

"october/system": "1.1.*",
"october/backend": "1.1.*",
"october/cms": "1.1.*",

Then the symlinking works and indeed my local repo is referenced, however the project fails since it's dependencies don't exist. So I'm confused on what I could do to fix this.

Upvotes: 1

Views: 326

Answers (1)

Barthy
Barthy

Reputation: 3231

Tell composer to use the develop branch, but create an inline alias to a version that satisfies the other dependencies:

{
    "require": {
        ...
    
        "october/rain": "dev-develop as 1.1.x-dev",

        ...
    }
}

For further development, I suggest you update the branch alias in the october/rain repository:

{
    "extra": {
        "branch-alias": {
            "dev-development": "1.1.x-dev"
        }
    }
}

This needs to change with each release / development phase.

Upvotes: 1

Related Questions