F_Z_14
F_Z_14

Reputation: 295

Why Composer install .git or .hg directories with package files?

I'm trying to publish composer package. I saved composer.json in my package directory:

{
    "name": "vendor_name/my_bundle",
    "type": "symfony-bundle",
    "autoload": {
        "psr-0": {
            "VendorName\\MyBundle": ""
        }
    },
    "target-dir": "VendorName/MyBundle"
}

But when I install it (composer update), with package files will added .hg directory.

Similar behaviour can be seen in this package: https://packagist.org/packages/tom32i/file-bundle (with package files will added .git directory: http://joxi.ru/uploads/prod/20130201/560/53a/136c5290b3c0f4c6f6318445f358d1d8cf30fe13.png)

Upvotes: 11

Views: 2881

Answers (2)

Lindsey D
Lindsey D

Reputation: 2857

Jakub's answer is great, and totally nails the solution...

In order to more permanently specify the dist version, simply add a preferred-install to your composer.json file:

{
    "config": {
        "preferred-install": "dist"
    }
}

Upvotes: 10

Jakub Zalas
Jakub Zalas

Reputation: 36191

Quote from the documentation:

There are two ways of downloading a package: source and dist. For stable versions composer will use the dist by default. The source is a version control repository.

The package you mentioned has no stable version, so composer downloads the source from git. Use --prefer-dist if you'd like composer to download package files (only happens if possible).

Upvotes: 13

Related Questions