Ankheur's avatar
Level 15

Composer can't find my forked vcs repository

Hello all !

After lots of threads looking to try to resolve a seemingly basic situation, I still can't figure out why it doesn't work for me. I want to use a notification channel which is not maintained : https://github.com/laravel-notification-channels/all-my-sms

So I've forked it as a public repository on my own github, made the changes and now I'm trying to include it in my project through composer. I'm using Laravel 9 for it but I've still changed it also for a Laravel 10 compatibility.

My composer.json (simplified) :

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/laravel-shift/laravel-page-speed.git"
        },
        {
            "type": "vcs",
            "url": "https://github.com/ankheur/all-my-sms.git"
        }
],
"require": {
    	"laravel-notification-channels/all-my-sms": "dev-l10",
        "renatomarinho/laravel-page-speed": "dev-l9-compatibility",
},
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "auto",
        "sort-packages": true,
        "allow-plugins": {
            "composer/package-versions-deprecated": true,
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "pestphp/pest-plugin": true,
            "php-http/discovery": true
        }
    }

I've left the laravel-page-speed package as this uses the same system I'm trying to use and it works for it but not for me.

For the config I've removed

"minimum-stability": "dev",
"prefer-stable": true

But it still doesn't work, even after a composer clear-cache and I'm still getting this error no matter what :

Problem 1
    - Root composer.json requires laravel-notification-channels/all-my-sms dev-l10, found laravel-notification-channels/all-my-sms[dev-master, dev-laravel-8, dev-analysis-8KEg3Q, v1.0.0, v1.0.1, v1.0.2, v1.1.0] but it does not match the constraint.

Composer doesn't install my fork and I don't know why, any ideas on what I'm doing wrong ?

0 likes
5 replies
LaryAI's avatar
Level 58

It seems like you're trying to require a specific branch (dev-l10) from your forked repository, but Composer is unable to find that branch. Here's a step-by-step guide to troubleshoot and resolve the issue:

  1. Verify the Branch Name: Ensure that the branch l10 actually exists in your forked repository. If the branch name is incorrect or the branch does not exist, Composer will not be able to find it.

  2. Check the Repository URL: Make sure that the URL provided in the repositories section of your composer.json file is correct and points to your forked repository.

  3. Use the Correct Branch Alias: If you want to alias your branch to a version, you can use the dev- prefix followed by the branch name. For example, if your branch is named l10, you should use dev-l10 in the require section.

  4. Clear Composer Cache: Sometimes, Composer might cache the old repository data. Run composer clear-cache to clear the cache and then try updating or installing again.

  5. Update Composer: Make sure you're using the latest version of Composer. Run composer self-update to update Composer to the latest version.

  6. Check Composer Stability Settings: If you've removed the minimum-stability and prefer-stable settings, Composer will default to stable versions, which might not include your dev branch. You can temporarily set "minimum-stability": "dev" to allow unstable packages.

Here's an example of how your composer.json should look:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ankheur/all-my-sms.git"
        }
    ],
    "require": {
        "laravel-notification-channels/all-my-sms": "dev-l10"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "auto",
        "sort-packages": true,
        "allow-plugins": {
            "composer/package-versions-deprecated": true,
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "pestphp/pest-plugin": true,
            "php-http/discovery": true
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

After making sure everything is correct, run the following command to update your dependencies:

composer update

If you've followed these steps and Composer still can't find your forked repository, double-check the branch name and the repository URL. If the problem persists, you might want to check the Composer documentation or seek support from the Composer community.

Ankheur's avatar
Level 15

@LaryAI Thank you Lary but after rechecking all the parameters all was fine and it doesn't resolve the problem :(

martinbean's avatar

@Ankheur

This reply was automagically generated by our local A.I. Think of it as a one-off attempt to instantly solve your problem. It will not respond to further replies.

Ankheur's avatar
Level 15

@martinbean I know, I just wanted to make clear that its answer didn't resolve the problem and I'm still in need of help

jjamesMTH's avatar

@ankheur I know this is a very old thread but came across it whilst trying to solve my own issues (unfortunately not the same).

I wonder if your repository declaration is incorrect. Maybe try something like:

"repositories":[
    {
	    "name":"myawesome/package",
	    "type":"vcs",
	    "url":"[email protected]:myawesome/package.git"
    }
]

Hopefully you've resolved this prior to me adding this comment.

Please or to participate in this conversation.