Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve CDK CLI version mismatch

Tags:

python

aws-cdk

I'm getting following error:

This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version. (Cloud assembly schema version mismatch: Maximum schema version supported is 8.0.0, but found 9.0.0)

after issuing cdk diff command.

I did run npm install -g aws-cdk@latest after which I've successfully installed new versions of packages: Successfully installed aws-cdk.assets-1.92.0 aws-cdk.aws-apigateway-1.92.0 aws-cdk.aws-apigatewayv2-1.92.0 ... etc. with pip install -r requirements.txt

However after typing cdk --version I'm still getting 1.85.0 (build 5f44668).

My part of setup.py is as follows:

    install_requires=[
    "aws-cdk.core==1.92.0",
    "aws-cdk.aws-ec2==1.92.0",
    "aws-cdk.aws_ecs==1.92.0",
    "aws-cdk.aws_elasticloadbalancingv2==1.92.0"
],

And I'm stuck now, as downgrading packages setup.py to 1.85.0 throwing ImportError: cannot import name 'CapacityProviderStrategy' from 'aws_cdk.aws_ecs'.

Help :), I would like to use newest packages version.

like image 499
Maciej Avatar asked Mar 10 '21 13:03

Maciej


4 Answers

I encountered this issue with a typescript package, after upgrading the cdk in package.json. As Maciej noted upgrading did not seem to work. I am installing the cdk cli with npm, and an uninstall followed by an install fixed the issue.

npm -g uninstall aws-cdk
npm -g install aws-cdk
like image 57
user113420 Avatar answered Oct 27 '22 02:10

user113420


So I've fixed it, but is too chaotic to describe the steps.

It seems like there are problems with the symlink

/usr/local/bin/cdk

which was pointing to version 1.85.0 and not the one I updated to 1.92.0.

I removed the aws-cdk from the node_modules and installed it again, then removed the symlink /usr/local/bin/cdk and recreated it manually with

ln -s /usr/lib/node_modules/aws-cdk/bin/cdk /usr/local/bin/cdk
like image 28
Maciej Avatar answered Oct 27 '22 02:10

Maciej


nothing helps for mac OS except this command:

yarn global upgrade aws-cdk@latest

like image 31
CloudA2Z Avatar answered Oct 27 '22 01:10

CloudA2Z


For those coming here that are not using a global install (using cdk from node_modules) and using a mono-repo. This issue is due to the aws-cdk package of the devDependencies not matching the version of the dependencies for the package.

I was using "aws-cdk": "2.18.0" in my root package.json but all my packages were using "aws-cdk-lib": "2.32.1" as their dependencies. By updating the root package.json to use "aws-cdk": "2.31.1" this solved the issue.

like image 2
Jeremy Avatar answered Oct 27 '22 03:10

Jeremy