I have the following in my composer.json, for bear/package it is picking up the alternative git repo, but not for bear/skeleton. For bear/skeleton it is getting the main repo checkout da04548 from packagist, rather than 6b3bd0ae16 from the github.com/mackstar account.
Does anyone know why this works for one repo and not the other?
Thanks in advance.
{
"name": "mackstar/spout",
"description":"A BEAR.Sunday based CMS",
"keywords":[
"PHP",
"CMS"
],
"authors":[
{
"name": "Richard McIntyre"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mackstar/BEAR.Skeleton"
},
{
"type": "vcs",
"url": "https://github.com/mackstar/BEAR.Package"
}
],
"require":{
"php":">=5.4.0",
"ext-curl":"*",
"bear/resource":"0.9.*",
"bear/skeleton":"dev-develop",
"bear/package":"dev-develop",
The issue is that the new bear/package introduced a require on composer/installers in version dev-master, which is not allowed by your minimum stability or requires, so that package can not be installed.
If you add "composer/installers":"#dev" to your requires or "minimum-stability":"dev" to the top level it should select the custom git repo for this package as well.
Related
To put it simpley the best I can: we have a private VC repo with a list of composer packages we use internally -- [our-bitbucket.com]/comp/
Each package has it's own repo. Each package is namespaced under [orgname]/ within their composer.json configuration.
What I'm trying to do is clean up this mess:
"repositories": [
{
"type": "vcs",
"url": "ssh://git#our-bitbucket.com/comp/package1",
"options": {
"ssh2": {
"username": "git",
"pubkey_file": ".ssh/pub-key",
"privkey_file": ".ssh/priv-key"
}
}
},
{
"type": "vcs",
"url": "ssh://git#our-bitbucket.com/comp/package2",
"options": {
"ssh2": {
"username": "git",
"pubkey_file": ".ssh/pub-key",
"privkey_file": ".ssh/priv-key"
}
}
},
// [... a dozen more times ...]
],
Is there any better and simpler way manage this? This repo list is getting pretty large. We need to clean it up. I don't suppose there's some way to add a global options for the keys? By host?
Here's a solution I found that assists in cleaning up this file: storing credentials in .ssh/config, modifying the URLs to match the config setting. e.g.
.ssh/config:
Host our-bitbucket.com
User git
IdentityFile /root/.ssh/priv-key
# ----------------------------
satis.json
"repositories": [
{"type": "vcs", "url": "ssh://git#our-bitbucket.com/comp/package2"},
//[... dozen more lines ...]
]
It at least saves us from having to define a priv/pub key for each and every repo definition.
I've got some packages host on the Gitlab of my company. I want to request a specific version of these packages but each time I try, composer download the latest commit of the master branch.
composer.json :
{
"name" : "MyProject",
"require" : {
"user/project" : "v0.5.0"
},
"type" : "project",
"repositories" : [
{
"url" : "git#gitlab.XXXX.fr:user/project.git",
"type" : "vcs"
}
],
"config" : {
"vendor-dir" : "private/class"
}
}
The structure of the repository of my package :
tag v0.5.0 : commit dd6ed3c8...
commit X,Y,Z
tag v0.7.0 : commit 15293ac6...
last commit f15600a1...
When I execute "composer install" :
Loading composer repositories with package information
Installing dependencies (including require-dev)
Analyzed 69 packages to resolve dependencies
Analyzed 67 rules to resolve dependencies
Installing user/project (dev-master f15600a)
Cloning f15600a1
It downloads the last commit only.
How can I configure the composer.json file of my project to use a specific tag ?
How to require a specific Git tag?
Change the version requirement to dev-master, followed by a hash # and the Git tag name, e.g. v0.5.0, like so:
"require": {
"vendor/package": "dev-master#v0.5.0"
}
How to require a specific Git commit?
Change the version requirement to dev-master, followed by a hash # and the Git commit reference, e.g. dd6ed3c8, like so:
"require": {
"vendor/package": "dev-master#dd6ed3c8"
}
Referencing: https://getcomposer.org/doc/04-schema.md#package-links
Define your own package and set version and reference
An alternative to working with repositories of "type": "vcs" is to define a custom package "type": "package" inside repositories and work with a reference.
The reference is either a Git commit hash, or a tag or branch name, like origin/master.
This will tie the version to a specific commit reference, in this case dd6ed3c8.
"repositories": [
# ...
{
"type": "package",
"package": {
"name": "vendor/package",
"version": "v0.5.0",
"source": {
"url": "git#gitlab.server.com:vendor/project.git",
"type": "git",
"reference": "dd6ed3c8"
}
}
}
]
Pull by git tag:
{
"repositories": [
{
"type": "git",
"url": "https://gitlab.xxx.com/some/repo.git"
}
],
"require": {
"some/repo": "1.0.2"
}
}
Pull by latest git commit:
{
"repositories": [
{
"type": "git",
"url": "https://gitlab.xxx.com/some/repo.git"
}
],
"require": {
"some/repo": "dev-master"
}
}
Pull by specific git commit:
{
"repositories": [
{
"type": "git",
"url": "https://gitlab.xxx.com/some/repo.git"
}
],
"require": {
"some/repo": "dev-master#68696f39"
}
}
Add repository via Composer Cli and pull latest git commit:
composer config repositories.repo git https://gitlab.xxx.com/some/repo.git
composer require "some/repo:dev-master"
composer update
To require a specific branch you can also just dev-branchname like this:
"require": {
"user/project" : "dev-my-branch"
},
You can use a specific version hash after '#', for example:
require": {
"user/project": "dev-master#31454f258f10329ae7c48763eb898a75c39e0a9f"
}
see: https://getcomposer.org/doc/04-schema.md#package-links
I have a rare case where I have two packagists in play here because I'm working on a Drupal Project. I have https://packagist.org and http://packagist.drupal-composer.org/.
The problem here is that they both define the package drupal/coder. One of them respects the composer.json, and the other does not, but generates one. I'm fixing to go create an issue over here that tells them to respect the composer.json is one is available.
I would like to use the package from packagist.org, but since I define packagist.drupal-composer.org, I'm not able to.
Is there a way to identify a package from a specific source, or to redefine a repository that already has a package.
I tried to add
{
"type": "vcs",
"url": "http://git.drupal.org/project/coder.git"
}
in my repositories to no avail. Doing a composer update; composer show simply shows me the package from packagist.drupal-composer.org. Additionally, defining:
{
"type": "composer",
"url": "http://packagist.org"
}
Provides me with the same results.
My last thought is to define a "package" and point it at the repository with a different name but seems like a lame work around because then I have to maintain "versions".
Yes thats definitely a problem. But here is a workaround, just the package definition above packagist.drupal-composer.org to your composer.json.
"repositories": [
{
"type": "composer",
"url": "https://packagist.org/p/drupal/coder.json"
},
{
"type": "composer",
"url": "http://packagist.drupal-composer.org"
}
]
You define Drupal's packagist as Composer type repo.
You define a git repo for the drupal/coder repo.
Both definitions go into the repository section.
Now: all packages are fetched from http://packagist.drupal-composer.org/, except drupal/coder.
Here you go:
{
"type": "project",
"repositories": [
{
"type": "git",
"url": "http://git.drupal.org/project/coder.git"
},
{
"type": "composer",
"url": "packagist.drupal-composer.org"
}
],
"require": {
"drupal/coder": "8.2.1"
}
}
I just put up a package on packagist and I tried to run a composer update and am getting the error:
Unknown downloader type: h. Available types: git, svn, hg, perforce, zip, rar, tar, gzip, phar, file.
In the main project file I have this:
"require": {
//.......
"cyphix333/sbb-code-parser": "dev-master"
},
The composer.json file for cyphix333/sbb-code-parser is:
{
"name": "cyphix333/sbb-code-parser",
"description": "SBBCodeParser is a simple BBCode parser",
"keywords": [
"SBBCodeParser"
],
"homepage": "https://github.com/samclarke/SBBCodeParser",
"canonical": "https://github.com/cyphix333/SBBCodeParser",
"source": "https://github.com/cyphix333/SBBCodeParser/tree/master",
"autoload": {
"classmap": ["SBBCodeParser.php","classes/"]
},
"authors": [
{
"name": "Sam Clarke"
}
],
"require": {
"php": ">=5.3"
}
}
I am not sure what I am doing wrong here?
If you just started getting this error, try composer clear-cache and/or delete ~/.composer and vendor.
The specific error I was getting was:
[InvalidArgumentException]
Unknown downloader type: . Available types: git, svn, fossil, hg, perforce, zip, rar, tar, gzip, xz, phar,
file, path.
I just deleted everything and then tried again; works now.
I'm using
Composer version 1.2.0 2016-07-19 01:28:52
I've solved this issue deleting the vendor directory.
rm -Rf vendor
And then running:
composer update
Changes to your composer.json: dropped canonical and source; added type library.
Give this one a try:
{
"name": "cyphix333/sbb-code-parser",
"description": "SBBCodeParser is a simple BBCode parser",
"homepage": "https://github.com/samclarke/SBBCodeParser",
"keywords": ["SBBCodeParser"],
"type": "library",
"authors": [
{
"name": "Sam Clarke"
}
],
"require": {
"php": ">=5.3"
},
"autoload": {
"classmap": ["SBBCodeParser.php", "classes/"]
}
}
I did resolve this error after updating the composer version.
The installation did not work with composer v2.
Passing to the v1 version works.
composer self-update --1
I encountered this issue too, we had a human error in our composer.json. The dist part of one of our custom repositories was entered with a faulty downloader type (as stated in the error message).
{
"type": "package",
"package": {
"name": "campaignmonitor/createsend-php",
"type": "drupal-library",
"version": "dev-master",
"dist": {
"url": "https://github.com/campaignmonitor/createsend-php.git",
"type": "drupal-library"
},
"source": {
"url": "https://github.com/campaignmonitor/createsend-php.git",
"type": "git",
"reference": "master"
}
}
}
Note that the dist's type is entered as drupal-library, that is the package type, not the downloader type. We corrected this by using the following for dist:
"dist": {
"url": "https://github.com/campaignmonitor/createsend-php/archive/master.zip",
"type": "zip"
},
As we developed this project we had no problems when running composer install locally. We encountered this error when making the project production ready, using --prefer-dist. Obviously, it will only then use dist over source and then encounter this error.
Disclaimer: This case is somewhat different then the original question, though it's highly relatable and this question came up on top when trying to search for the answer. I hope this is okay.
I've successfully set up Satis on my own server and am able to pull in packages from it.
However, dependencies that are required in those private packages are constantly being cloned at their bleeding edge version instead of the specified version constraint. I think that Satis is creating a local mirror of the latest dev-version. However I do not want to have a local mirror, I just need them to install directly from Packagist.
So how do I need to setup the project / package / Satis to have the dependencies in those private packages installed from Packagist?
Thanks.
This is my Satis build file:
{
"name": "Package Server",
"homepage": "http://packages.URL",
"repositories": [
{
"type": "vcs",
"url": "git#bitbucket.org:USERNAME/REPO.git",
"options": {
"ssh2": {
"username": "USERNAME",
"pubkey_file": "PUBFILE",
"privkey_file": "PRIVATEFILE"
}
}
}
],
"require-all": true
}
And this is the composer.json file of the project requiring the private package (package has no tagged releases):
{
"name": "Test Project",
"description": "",
"require": {
"php": ">=5.4.0",
"USERNAME/REPO": "*"
},
"repositories": [
{
"type": "composer",
"url": "http://packages.URL"
}
],
"minimum-stability": "dev"
}
And this is the private package's composer.json:
{
"name": "USERNAME/RPO",
"description": "",
"require": {
"php": ">=5.4.0",
"illuminate/support": "5.0.*",
"vinkla/hashids": "~1.0"
},
"minimum-stability": "dev"
}
In your Satis config you defined "require-all": true.
This is default and selects all versions of all packages in the repository you defined.
You could try to remove "require-all": true in favor of a require section.
This means that Satis will only contain these specific packages and their versions, like so:
"require": {
"company/packageA": "*",
"company/packageB": "1.2.3",
"company/packageC": "2.0.0"
}
It's package cherry picking on Satis
So if I understand correctly I need to add the private packages that are available in the specified private repository in the require key and their own dependencies will then install from Packagist?
Add require-dependencies - this tells Satis to mirror not only the packages specified in the "require" section, but also all their dependencies.
See https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md#resolving-dependencies
Is it possible to have multiple packages resided in one defined repository or does every single package need their own repository url entry in Satis?
I think it's not possible to have multiple packages in one "type": "vcs" repository.
With "type": "composer" and a cloned packagist you can store multiple repos.
Think of http://drupal-composer.org with http://packagist.drupal-composer.org/.
{
"repositories": [
{ "type": "vcs", "url": "https://github.com/somewhere/packageA" },
{ "type": "composer", "url": "https://packagist.org" }
],
"require": {
"package/packageA": "somewhere-dev",
"phpunit/phpunit": "*"
},
"require-dependencies": true
}