Private composer packages - no valid composer.json was found

James

I'm trying to load a library I have hosted on BitBucket using composer as explained both in the official documentation and here, but keep receiving the following error:

[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of [repository URL], could not load a package from it.

Here is my project composer.json:

{
    "name": "Project name",
    "require": {
        "my-vendor/my-package": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": [repository URL]
        }
    ]
}

And here is the composer.json in my remote repository (that apparently can't be found):

{
    "name": "my-vendor/my-package",
    "version": "0.3",
    "autoload": {
        "psr-0": {
            "NS_": "src"
        }
    }
}

I should mention that both composer.json files are in the root directory as they should be.

Some other things to note:

I've also tried the "non-composer package" approach, whereby I specify the package information in my project composer.json, and omit the composer.json from my remote repository, as outlined in the documentation. This successfully clones the master branch but then results in the following error:

[RuntimeException]
Failed to execute git checkout "master" && git reset --hard "master"

fatal: Not a git repository (or any of the parent directories): .git

However, the package is downloaded to /vendor as expected, so I'm not sure why it's trying to checkout master again.

This is not the way I wish to solve this problem (as I'd rather make use of a composer.json in the remote repository), but it might help identify an issue elsewhere.

Thanks for any help.

EDIT

I've managed to get it working by referencing a package.json over HTTP:

"repositories": [
    {
        "type": "composer",
        "url": "http://localhost/packages.json"
    }
]

The packages.json looks like:

{
    "packages": {
        "vendor/my-package": {
            "dev-master": {
                "name": "vendor/my-package",
                "version": "dev-master",
                "source": {
                    "url": [repository URL],
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    }
}

Is this the only way to get this working? It seems a bit overkill to host my own packages.json file if I'm only going to be using one or two in-house packages.

Regardless, this is giving me the same Git error as I mentioned previously.

EDIT 2

Forcing an error (invalid SSH passphrase) gives this:

[RuntimeException]
Failed to execute git clone "[repository URL]" "C:\workspace\DFv3\vendor\vendor/my-package" && cd /D "C:\workspace\DFv3\vendor\vendor/my-package" && git remote add composer "[repository URL]" && git fetch composer

So I can clearly see what it's doing here. However, it seems after this command runs it cds into the .git directory and tries running:

git checkout "master" && git reset --hard "master"

Presumably to get rid of the composer instance it pulled. However, it's running this in the wrong directory and I can't figure out why..

James

I've managed to get it working by referencing a package.json over HTTP:

"repositories": [
    {
        "type": "composer",
        "url": "http://localhost/packages.json"
    }
]

so the packages.json file looks like:

{
    "packages": {
        "vendor/my-package": {
            "dev-master": {
                "name": "vendor/my-package",
                "version": "dev-master",
                "source": {
                    "url": [repository URL],
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    }
}

Also, its seems an autorun registry entry I had for command prompt was interfering with composer running.

See: Requiring a private git Bitbucket repository fails to find valid composer.json.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Composer package not found in private repository

From Dev

Composer private Bitbucket repository cannot be found

From Dev

Private repo composer.json not being used

From Dev

Private repo composer.json not being used

From Dev

composer.json specifies dependency, but no composer.lock was found

From Dev

No composer.json found in the current directory

From Dev

composer.json error: "./composer.json" does not contain valid JSON

From Dev

Adding multiple Composer packages

From Dev

Where are composer packages installed?

From Dev

Composer, Laravel and local packages

From Dev

Composer dowloading not specified packages

From Dev

Installing multiple packages with composer?

From Dev

Where are composer packages installed?

From Dev

Composer dowloading not specified packages

From Dev

Composer local packages

From Dev

Travis configuration for composer packages

From Dev

Composer specifying 'in development' packages?

From Dev

Composer Private Repository Problems

From Dev

composer.json correct structure for multiple PHP packages

From Dev

Composer.json require my own private package

From Dev

Composer - No Matching Package Found

From Dev

Composer: Command Not Found

From Dev

Composer Package not found

From Dev

Composer autoload, class not found

From Dev

Proper directory structure for composer packages that require other composer packages?

From Dev

Composer not downloading src directory for packages

From Dev

Excluding files from composer packages

From Dev

Different Composer packages with same namespace

From Dev

reload all packages using composer