Configuring composer.json with private bitbucket mercurial repository

2,391 views
Skip to first unread message

Roman

unread,
Feb 20, 2015, 5:03:03 AM2/20/15
to compose...@googlegroups.com

My project uses my own library which is in the private mercurial repository placed on bitbucket.org. That library has no composer.json configured.

I try to make that library as a dependency to my project. And can't get it for the second day.

Firstly I wrote to composer.json the following strings:  

  {
    "require": {
      "php": ">=5.4",
      "myname/mylibname": "dev"
    },

    "repositories":[
      {
        "type": "hg",
      }
    ]
  }


And running composer install I've got an error:

[RuntimeException]
Failed to clone https://bitbucket.org/myname/mylibname, could not read packages from it
abort: http authorization required
 
Than I changed "type": "hg" to "type": "vcs" and got another error:
[Composer\Repository\InvalidRepositoryException] 
No valid composer.json was found in any branch or tag of https://bitbucket.org/myname/mylibname
could not load a package from it.

After additional reading of documentation I added description of my library to the composer.json of my project, and it began to look so:
{
  "require": {
    "php": ">=5.4",
    "myname/mylibname": "dev"
  },

  "repositories":[
    {
      "type": "vcs",
    },
    {
      "type":"package",
      "package":{
        "name":"myname/mylibname",
        "version": "dev",
        "source":{
          "type":"vcs",
          "reference":"dev"
        }
      }
    }
  ]
}


The same error occured:
[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of https://bitbucket.org/myname/mylibname, could not load a package from it.


I removed the part:
{
  "type": "vcs",
},

and got an error:
[InvalidArgumentException]                                                                               
Unknown downloader type: vcs. Available types: git, svn, hg, perforce, zip, rar, tar, gzip, phar, file.

I changed "type": "vcs" back to "type": "hg", composer.json looks like:
  {
    "require": {
      "php": ">=5.4",
      "myname/mylibname": "dev"
    },
        "repositories":[
      {
        "type":"package",
        "package":{
          "name":"myname/mylibname",
          "version": "dev",
          "source":{
            "type":"hg",
            "url":"https://bitbucket.org/myname/mylibname",
            "reference":"dev"
          }
        }
      }
    ]
  }

and an error:
[RuntimeException]                                                                                                                      
Failed to execute hg clone 'https://bitbucket.org/myname/mylibname'  '/path/to/myproject'
abort: http authorization required 

The structure of my auth.json, which lies besides of composer.json is:
{
  "http-basic": {
    "bitbucket.org": {
      "username": "myusername",
      "password": "mypassword"
    }
  }
}

Nothing helps. So I'm stuck and need help.
 

Christophe COEVOET

unread,
Feb 20, 2015, 5:11:08 AM2/20/15
to compose...@googlegroups.com
the "vcs" repository type expects to find a composer.json file in the repo being linked.

Using a "package" repository type should be avoided whenever possible as it is much harder to use (to have dependency locking and updates working properly, it requires a lot of manual work given that Composer usually does a lot of work automatically based on the git, hg or svn metadata and it cannot do it for inline repositories). When the library is under your own control, the best way (by far) is to add a composer.json file in the repo.
--
You received this message because you are subscribed to the Google Groups "composer-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to composer-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Christophe | Stof

Roman

unread,
Feb 20, 2015, 8:08:14 AM2/20/15
to compose...@googlegroups.com
Thanks for the answer. Actually I wanted to achieve the working state of my project with configuring "package" for my library in my project composer.json. And the result is - I didn't get this.

So I added composer.json to my library repository, 'composer install' done his job well except one moment - despite of auth.json it still can not get authorisation, and downloaded my library from bitbucket as a zip archive.

The composer.json in my project:
{
 "require": {
  "php": ">=5.4",
  "myname/mylib": "dev-dev"
 },
 "repositories":[
  {
   "type":"vcs",
  }
 ]
}

The composer.json in my library:
{
 "name": "myname/mylib",
 "require": {
  "php": ">=5.4",
  "ext-phalcon": "1.3.2"
 }
}

The message while installing:

Failed: [RuntimeException] Failed to execute hg clone 'https://bitbucket.org/myname/mylib' '/path/to/myproject/vendor/myname/mylib'

abort: http authorization required

    Failed to download myname/mylib from source: Failed to execute hg clone 'https://bitbucket.org/myname/mylib'/path/to/myproject/vendor/myname/mylib'

abort: http authorization required

    Now trying to download from dist

  - Installing myname/mylib (dev-dev 324f1d6) 

As I mentioned, the installation finished successfully, library is downloaded properly, but that message about authorization failure means that either I am doing something wrong or there is a bug or there is no implementation for private mercurial repositories on bitbucket.
Reply all
Reply to author
Forward
0 new messages