When using the commands 'composer update', 'composer require' or 'composer remove' (other modules), I get the following error:
[RuntimeException]
Could not load package drupal/campaignmonitor in https://packages.drupal.org/8: [UnexpectedVal
ueException] Could not parse version constraint {version}: Invalid version string "{version}"
[UnexpectedValueException]
Could not parse version constraint {version}: Invalid version string "{version}"This error also occurs when trying to require campaignmonitor on a different project.
Steps to reproduce:
1. Download Drupal
2. Composer install
3. Composer require drupal/campaginmonitor
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | campaign_monitor.png | 51.66 KB | lcontreras |
Comments
Comment #2
davidarbour commentedThis apply to all version, giving same error with ^2.0
composer require 'drupal/campaignmonitor:^2.0'Comment #3
tim-dielsYeah experiencing same issue by just trying to update my lock file.
Seem to be again the issue like described in #2906369: Composer issue for campaignmonitor?
Comment #4
lcontreras commented@tim-diels I'm having same issue too just trying to remove another drupal module. Also, I've found same issue already fixed in a previous version but the fix is not working anymore:
https://www.drupal.org/project/campaignmonitor/issues/2887580
Comment #5
lcontreras commentedThere is a commit from yesterday on the json file.
https://git.drupalcode.org/project/campaignmonitor/-/blob/9afe72d6a0549c...
They have added this line:
"drupal/core": "^8 || ^9",
Comment #6
meanderix commentedI'm experiencing this as well. I was only able to get rid of the error by manually removing the module.
Edit: I also removed composer.lock (and created a new one with
composer update --lock).Comment #7
davidarbour commentedManually removing the module worked for me on composer install only. I cannot update other package. This will break deployment that use composer to build.
Comment #8
mmjvb commentedYou are not allowed to make such mistakes. The composer.json needs to be valid at all times. Once a bad composer.json is released, you are in trouble. The module can no longer be used with composer.
Try an issue with https://www.drupal.org/project/project_composer requesting a manual fix. You are not the first one/only one having experienced this. You might want to check the issue queue for similar issues.
Found one: https://www.drupal.org/project/project_composer/issues/3102755
Generic fix: https://www.drupal.org/project/project_composer/issues/3076342
The only alternative I know is to abandon this project and move to a new namespace. Obviously, without errors in composer.json.
Also suggest to make `composer validate` part of your make release or commit strategy.
Comment #9
meanderix commented@mmjvb: I'm not the maintainer of this module, but it seems rather drastic to have to create a completely new namespace? Also, it seems like a rather big security issue that existing modules may break composer deployments simply by committing an erroneous composer.json. I don't fancy the idea the my composer deployments (usually locked to specific module versions) will break when a commit occurs (especially when considering automatic build schemes and kubernetes etc).
Looks like the the core issue needs to be addressed in the project_composer queue:
#3076342: Filter out bad version constraints
Comment #10
BarisW commentedIn 2017, the composer file has changed from
campaignmonitor/createsend-php": "{version}"tocampaignmonitor/createsend-php": "^5.0.2". Why does it now lead to broken builds?I cannot add/update any module now in my project. Any tips on how to ignore/fix this?
Comment #11
meanderix commentedComment #12
meanderix commented@BarisW: see comment #6, that worked for me.
Comment #13
meanderix commentedComment #14
lcontreras commentedWhat I don't really understand is why composer.json seems to be valid once you test the module separately, it is running any composer command inside the module path without any error. Also, the error show by composer says '......Invalid version string "{version}' the last module version doesn't contain {version} on the composer.json file.
Comment #15
BarisW commentedYeah, I noticed that too. This error was already fixed in 2017: https://git.drupalcode.org/project/campaignmonitor/commit/1d1db8c
So why it's popping up now: no clue :(
Comment #16
lcontreras commented@BarisW Could be composer try to download a previous module version for some reason even we are asking ^2.0. It doesn't sound logical TBH.
Comment #17
lcontreras commentedSeems that composer is not installing the right version because it doesn't match with drupal core requirements. The line they committed 2 days ago, I'm not quite sure because other modules are asking the same drupal/core requirements for the compatibility with drupal 9 and are working properly:
https://www.drupal.org/node/3127396
Something similar happened with migrate Upgrade module:
https://www.drupal.org/project/migrate_upgrade/issues/3008682#comment-12...
Comment #18
lcontreras commentedMaintainers fixed it, removing the last change. Composer is not failing anymore.
Comment #19
vladimirausAs per my discovery on #3127396: Drupal 9 compatibility:
Composer Json manifest contains errors passed from poorly defined composer.json for older versions.
Seems like those errors didn't kicked in until semantic versioning was switch on.
https://packages.drupal.org/8/drupal/campaignmonitor%248295169748a199564...
{version}was placed incomposer.jsonfor the following releasesComment #20
mmjvb commentedTry un-publishing those releases. Sounds like those database edits are reverted, suggest to request @mixologic to do them again.
Comment #22
lcontreras commented@VladimirAus after last commit is failing again, now composer run to install/update/remove other modules, but not able to install cmapaignmonitor, same error.
Comment #23
vladimiraus@lcontreras: as mentioned in #3127396: Drupal 9 compatibility - commits won't affect the issue. Someone with admin permissions needs to unpublish the following releases:
and regenerate JSON manifest
I asked for help on slack.
Unfortunately we can only wait.
Comment #24
lcontreras commented@VladimirAus okay thanks for the effort :)
Comment #25
aburrows commented@VladimirAus whom do we need to get to do this?
Comment #26
vladimiraus@aburrows I created issue #3132985: Bad json manifest causes composer "Could not parse version constraint {version}" error in
Drupal Infrastructure(recommended by @xjm on Slack).Comment #27
robin.ingelbrecht commentedCan someone point out how to fix this? Removing and re-installing the module does not work, still get the error mentioned by OP.
I'm unable to do anything composer related...
Comment #28
mmjvb commentedSeveral solutions have been pointed out already, unfortunately none of them available as of now. There is nothing you can do to fix it, it requires others to do something.
You could temporarily not use composer for this module. Replace it with campaignmonitor/createsend-php as that is a requirement. Probably needs manual edit of composer.json/composer.lock to remove it. Then either manually extend or use Ludwig for drupal/campaignmonitor till issue resolved.
Tried to fix it at the source: vendor/composer/semver/src/VersionParser.php
but it didn't workout.
Also tried to manipulate the cached information. Unfortunately, that keeps being refreshed. Maybe that is because I didn't have it installed already, the information is in: provider-drupal$campaignmonitor.json, not in something like drupal-provider-2020-2.json.
EDIT
The composer.phar includes semver/src/VersionParser.php. Either extract the phar or add your change to it.
Comment #29
robin.ingelbrecht commentedOr maybe treat this module as a custom module for now? Exclude it from .gitignore and commit it into my repo...
Comment #30
robin.ingelbrecht commentedI solved it like this:
These steps will remove campaignmonitor from your composer managed modules and thus it will be treated as a custom module (it will be added to your git repository). When this problem is fixed, just reverse these steps and require the module as normal
Comment #31
mmjvb commentedNot really a need for treating it as a custom module. There is nothing wrong with the current state of the module. It is the meta data provided that is not liked by composer. That meta data is corrected in newer releases. Unfortunately, it is not allowed to fix old meta on d.o. Extending like you did before composer is enough.
EDIT
Manually extending instead of using composer doesn't make it a custom module, it remains a contrib module till you customize it.
Comment #32
robin.ingelbrecht commentedI know there is nothing wrong with the module itself, but nevertheless, it blocks our complete development flow, so we need to get this out of composer until this issue is fixed.
So basically, for the time being, it is required to treat this as a custom module (except if you do not want to update or install any modules through composer of course)
Comment #33
mmjvb commentedMaintainers might want to investigate Narrowsparc-Automatic
It complements composer and should allow restricting versions. That way you could skip the bad versions.
Consumers might be interested in Studio to overrule the facade from d.o. for this module. Rather than manual downloading, it continues to use composer, but prefers a local version to the one from d.o.
Comment #34
lcontreras commented@mmjvb Thanks for this suggestion.
Comment #35
mmjvb commentedMy first read of the automatic plugin gave me the impression your app (Drupal module) would need to have a configuration file. Hence I targeted it for the maintainers of the module. It looks like you can use it without adding anything to your module. See
https://github.com/narrowspark/automatic#automatic-extends-composer
This makes it interesting for consumers as well. Sounds like just requiring automatic for your site and adding the extra key for skipping the bad releases should solve the issue.
EDIT: Unfortunately not
Comment #36
mmjvb commentedThose running Composer v2 could add a package repository. In v2 repositories are authoritative by default. That means it stops looking when found. It no longer scans all repositories for the same same package.
Comment #37
drumm#3076342: Filter out bad version constraints has been deployed to Drupal.org and I re-processed the Composer metadata for this project. I expect this will resolve the issue.
Comment #38
mmjvb commentedConfirmed:
Comment #39
drummComment #40
stefaniev commentedThanks for solving the issue!
Comment #41
vladimirausThanks everyone!
Comment #42
davidarbour commentedThanks for solving this :)