How to replace composer package with an alternative. Problem. Old pkg removal failed

I’m wondering if anyone knows how to replace one denendency/package with another.
I’m trying to replace an outdated dynamic/silverstripe-linkable with an alternative gorriecoe/silverstripe-link.

The dynamic/silverstripe-linkable is needed by dynamic/silverstripe-elemental-baseobject

composer why dynamic/silverstripe-linkable
dynamic/silverstripe-elemental-baseobject 2.1.0 requires dynamic/silverstripe-linkable (^1.0)
dynamic/silverstripe-linkable             1.0.2 replaces sheadawson/silverstripe-linkable (^2.0)

I installed an alternative package:

composer require gorriecoe/silverstripe-link

and added the following to its composer.json:

  "replace": {
    "dynamic/silverstripe-linkable": "*",
    "sheadawson/silverstripe-linkable": "*"

Everything looks ok for me.
I intended to remove the old dynamic’s package and require an alternative gorricoe’s package and everything should work because I specified a “replace” section in the composer.json of the new alternative (gorriecoe/silverstripe-link) package.

Problem: composer fails to remove the old package because it thinks that ‘dynamic/silverstripe-linkable’ is still needed.
If I remove the directory dynamic/silverstripe-linkable manually then this package is installed again on composer update.


When I do

composer remove  dynamic/silverstripe-linkable

it says:

Removal failed, dynamic/silverstripe-linkable is still present, it may be required by another package

I also tried

composer remove --no-update dynamic/silverstripe-linkable

and then composer update -W
That does not work too.

Reason: I need to replace the old dynamic/silverstripe-linkable package because it is outdated and uses the old embed/embed^3 which prevents the composer from updating to silverstripe^4.11.

Please help if anyone knows what am I doing wrong. Thank you!

Looks like you’ve already posted this same question in Stuck with composer update Silverstripe 4.10 -> 4.11.
Please avoid posting the same question twice.

Okay, sure. I just didn’t know that this is the same question for that moment.

You may delete the topic. Solved.