Skip to content

Rector doesn't read from composer.json's config.vendor-dir to find vendor/composer/installed.json when using Rector\Configuration\RectorConfigBuilder::withComposerBased #9058

@cdayjr

Description

@cdayjr

Bug Report

Subject Details
Rector version Rector 2.0.10

I have a composer.json file with the platform.vendor-dir property set, it looks something like this:

{
  "config": {
    "vendor-dir": "httpdocs/vendor"
  }
}

For background, per https://getcomposer.org/doc/06-config.md#vendor-dir this is how the setting is described:

Defaults to vendor. You can install dependencies into a different directory if you want to. $HOME and ~ will be replaced by your home directory's path in vendor-dir and all *-dir options below.

When I run rector (including just --version) with the Rector\Configuration\RectorConfigBuilder::withComposerBased configuration method I get the following error:

[ERROR] The installed package json not found. Make sure you run `composer update` and the "vendor/composer/installed.json" file exists

Seems like InstalledPackageResolver always gets created with \getcwd()

$setManager = new SetManager($setProviderCollector, new InstalledPackageResolver(\getcwd()));

and inside that always expects the platform.vendor-dir value to be the default with this hard-coded path:

$installedPackagesFilePath = $this->projectDirectory . '/vendor/composer/installed.json';

Not quite sure if this is technically a bug or a feature request, but I figure since it says "not found" and composer.json says where it is that seems more like a bug to me.

I can work around it by making a symlink in the spot it's looking for to where the installed.json file is, but it does make my directories a bit messier.

Thanks for taking a look!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions