Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer custom package error : Skipped branch develop, Undefined index: name

I am trying to load a small package I made from a remote git repository but i'm still getting the same error whatever I do.

Here is the code of the local composer I am running :

{
"require": {
    "kdyby/fake-session": "^2.0",
    "monolog/monolog": "^1.19",
},

"repositories": [
    {
        "type": "git",
        "url": "http://xxxx/master/Core.git" }
],

"config": 
    {
        "secure-http": false
    }
}

And this is the remote composer.json :

{
"repositories": [
    {
        "type": "package",
        "package": {
            "name": "master/core",
            "version": "dev-master",
            "source": {
                "url": "http://xxxx/master/Core.git",
                "type": "git",
                "reference": "origin/develop"
            }
        }
    }
],
"require": {
    "master/core": "dev-master"
    }
}

Here are the logs from my console :

   $ composer require master/Core
   Reading composer.json of http://xxxx/master/Core.git (develop)
   Skipped branch develop, Undefined index: name

   [Composer\Repository\InvalidRepositoryException]
   No valid composer.json was found in any branch or tag of http://xxxx/master/Core.git, could not load a package from it.

Note that I am trying to get the files from the develop branch and I guess it's reaching the composer.json since it's saying there is an error.

The owner of the repository is "master", that's why there is a master/core, nothing to do here with the master branch.

I've found many issues about undefined index version, but didn't find a working fix for the undefined index name. I tried many version of the remote composer file with examples/fixes from the internet, but none worked.

There must be an obvious issue in my files, or something i don't get about composer. Thanks for any help.

Edit : solved my issue, i was wrong on which side having which file.

It's working with local composer.json :

{
"repositories": [
    {
        "type": "package",
        "package": {
            "name": "master/core",
            "version": "dev",
            "source": {
                "url": "http://xxxx/master/Core.git",
                "type": "git",
                "reference": "develop"
            }
        }
    }
],
"require": {
    "master/core": "dev"
    }
}

and remote composer.json :

{
"name": "master/Core"
}

Note : You must have the composer.json gitted even if working with local files for both (local and remote) or it will not work if you use a "type":"git".

like image 375
Jean-Loup Becquet Avatar asked Oct 31 '22 01:10

Jean-Loup Becquet


1 Answers

You have to create composer.json file

and it should have at least those information:

{
    "name": "your-vendor-name/package-name",
    "description": "A short description of what your package does"
}

Reference: https://packagist.org/

like image 198
AboElnouR Avatar answered Nov 13 '22 07:11

AboElnouR