Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing directory separator in FileDownloader #9426

Conversation

UrGuardian4ngel
Copy link
Contributor

In a project I'm working on, we have some dependencies on libraries outside of the composer ecosystem.
To do so, we are defining those external dependencies as file-typed packages.

We're currently working on migrating to composer v2.x, when I noticed an anomaly...

When installing a package with dist.type: 'file', it appears that the file gets installed in the wrong target destination?

Reproduction steps

I've created a minimal composer.json file that reproduces this issue in composer v2.x.

Sample composer.json
{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "composer/readme-file",
                "version": "2.0.4",
                "dist": {
                    "url": "https://raw.githubusercontent.com/composer/composer/2.0.4/README.md",
                    "type": "file"
                }
            }
        }
    ],
    "require": {
        "composer/readme-file": "2.x"
    }
}

This example contains a composer/readme-file package, which pulls in the README.md file of this repository as a composer "package".

Expected behavior

As the package name is composer/readme-file, I'd expect the file to be stored at vendor/composer/readme-file/README.md.
This is also what happens with composer v1.x:

$ ./composer.phar -V
Composer version 1.10.17 2020-10-30 22:31:58

$ ./composer.phar install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing composer/readme-file (2.0.4): Loading from cache
Writing lock file
Generating autoload files

$ tree ./vendor/
./vendor/
├── autoload.php
└── composer
    ├── ...
    └── readme-file
        └── README.md

Actual behavior

However, in composer v2.x, this is not the case anymore.

The file is stored as vendor/composer/readme-fileREADME.md (so concatenated and directly under the vendor/composer parent, as opposed to in its own vendor/composer/readme-file subdirectory):

$ ./composer.phar -V
Composer version 2.0.3 2020-10-28 15:50:55

$ ./composer.phar install
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking composer/readme-file (2.0.4)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing composer/readme-file (2.0.4)
Generating autoload files

$ tree ./vendor/
./vendor/
├── autoload.php
└── composer
    ├── ...
    └── readme-fileREADME.md

@Seldaek Seldaek merged commit 2a8cc06 into composer:master Nov 6, 2020
@Seldaek
Copy link
Member

Seldaek commented Nov 6, 2020

Thanks

@Seldaek Seldaek added this to the 2.0 milestone Nov 6, 2020
@Seldaek Seldaek added the Bug label Nov 6, 2020
@UrGuardian4ngel UrGuardian4ngel deleted the bugfix/add-missing-directory-separator-in-file-downloader branch November 6, 2020 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants