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

aws-cdk-lib: Error jsii.errors.JavaScriptError when running any CDK command #31508

Closed
1 task
tfotis opened this issue Sep 20, 2024 · 4 comments
Closed
1 task
Labels
aws-cdk-lib Related to the aws-cdk-lib package bug This issue is a bug. effort/medium Medium work item – several days of effort p3

Comments

@tfotis
Copy link

tfotis commented Sep 20, 2024

Describe the bug

My CDK project isn't working anymore.

It used to work fine, but suddenly whenever I try to run any CDK command (list, bootstrap etc), I get an error.

I tried with different versions of the CDK library and different versions of Python but the error is the same, however I am unable to pinpoint the reason or figure out the solution.

The error I am getting is the following:

jsii.errors.JavaScriptError: 
  @jsii/kernel.Fault: Error for package tarball /home/sandbox/cdk/hello-cdk/.venv/lib/python3.12/site-packages/aws_cdk/asset_kubectl_v20/_jsii/asset-kubectl-v20@2.1.2.jsii.tgz: Expected to find .jsii file in /tmp/jsii-kernel-FLXr64/node_modules/@aws-cdk/asset-kubectl-v20, but no such file found
      at Kernel._Kernel_load (/tmp/tmplk8mak5x/lib/program.js:9056:23)
      at /tmp/tmplk8mak5x/lib/program.js:8778:181
      at Kernel._Kernel_debugTime (/tmp/tmplk8mak5x/lib/program.js:9490:24)
      at Kernel.load (/tmp/tmplk8mak5x/lib/program.js:8778:96)
      at KernelHost.processRequest (/tmp/tmplk8mak5x/lib/program.js:10715:36)
      at KernelHost.run (/tmp/tmplk8mak5x/lib/program.js:10675:22)
      at Immediate._onImmediate (/tmp/tmplk8mak5x/lib/program.js:10676:46)
      at process.processImmediate (node:internal/timers:476:21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/sandbox/cdk/hello-cdk/app.py", line 4, in <module>
    import aws_cdk as cdk
  File "/home/sandbox/cdk/hello-cdk/.venv/lib/python3.12/site-packages/aws_cdk/__init__.py", line 1534, in <module>
    from ._jsii import *
  File "/home/sandbox/cdk/hello-cdk/.venv/lib/python3.12/site-packages/aws_cdk/_jsii/__init__.py", line 32, in <module>
    import aws_cdk.asset_kubectl_v20._jsii
  File "/home/sandbox/cdk/hello-cdk/.venv/lib/python3.12/site-packages/aws_cdk/asset_kubectl_v20/_jsii/__init__.py", line 13, in <module>
    __jsii_assembly__ = jsii.JSIIAssembly.load(
                        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sandbox/cdk/hello-cdk/.venv/lib/python3.12/site-packages/jsii/_runtime.py", line 55, in load
    _kernel.load(assembly.name, assembly.version, os.fspath(assembly_path))
  File "/home/sandbox/cdk/hello-cdk/.venv/lib/python3.12/site-packages/jsii/_kernel/__init__.py", line 299, in load
    self.provider.load(LoadRequest(name=name, version=version, tarball=tarball))
  File "/home/sandbox/cdk/hello-cdk/.venv/lib/python3.12/site-packages/jsii/_kernel/providers/process.py", line 354, in load
    return self._process.send(request, LoadResponse)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sandbox/cdk/hello-cdk/.venv/lib/python3.12/site-packages/jsii/_kernel/providers/process.py", line 341, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Error for package tarball /home/sandbox/cdk/hello-cdk/.venv/lib/python3.12/site-packages/aws_cdk/asset_kubectl_v20/_jsii/asset-kubectl-v20@2.1.2.jsii.tgz: Expected to find .jsii file in /tmp/jsii-kernel-FLXr64/node_modules/@aws-cdk/asset-kubectl-v20, but no such file found

Subprocess exited with error 1

To make sure that the problem doesn't lie with my specific project, I created a new CDK project (with python language) from scratch by following the exact steps described here.

When I reach Step 3 and try to bootstrap the AWS environment, I get the error above.

Some information from my system

  • Python: 3.12.5
  • CDK: 2.159.1 (build c66f4e3)
  • Node: v18.18.0

Virtual Environment

attrs==24.2.0
aws-cdk-lib==2.159.1
aws-cdk.asset-awscli-v1==2.2.203
aws-cdk.asset-kubectl-v20==2.1.2
aws-cdk.asset-node-proxy-agent-v6==2.1.0
aws-cdk.cloud-assembly-schema==36.3.0
cattrs==23.2.3
constructs==10.3.0
importlib_resources==6.4.5
jsii==1.103.1
publication==0.0.3
python-dateutil==2.9.0.post0
six==1.16.0
typeguard==2.13.3
typing_extensions==4.12.2

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

2.103.1

Expected Behavior

The CDK command to work correctly without any errors

Current Behavior

I get an error whenever I try to run any CDK command

Reproduction Steps

Follow the steps described here to create a new CDK project with python language

Possible Solution

I am not sure

Additional Information/Context

No response

CDK CLI Version

2.159.1 (build c66f4e3)

Framework Version

No response

Node.js Version

v18.18.0

OS

Manjaro Linux

Language

Python

Language Version

3.12.5

Other information

No response

@tfotis tfotis added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 20, 2024
@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Sep 20, 2024
@pahud pahud self-assigned this Sep 20, 2024
@pahud
Copy link
Contributor

pahud commented Sep 20, 2024

Can't reproduce.

It used to work fine, but suddenly whenever I try to run any CDK command (list, bootstrap etc), I get an error.

Did it happen when you just upgrade your CDK version to 2.159.1 without changing any code? Do you remember what you have changed?

When I reach Step 3 and try to bootstrap the AWS environment, I get the error above.

You don't need cdk bootstrap if you have already bootstrapped your account/region.

With a fresh new cdk in python repo:

  1. Are you able to run cdk ls to list stacks? If not, what's the full error message?
  2. If cdk ls is failing at 2.159.1, do you remember what is your last working version? Can you change back to that version and try again?
  3. Please make sure your CDK CLI and lib version are consistent i.e.
% cdk --version
2.159.1 (build c66f4e3)
 % grep aws-cdk requirements.txt 
aws-cdk-lib==2.159.1

@pahud pahud added p3 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Sep 20, 2024
@pahud pahud removed their assignment Sep 20, 2024
@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 20, 2024
@tfotis
Copy link
Author

tfotis commented Sep 22, 2024

Did it happen when you just upgrade your CDK version to 2.159.1 without changing any code? Do you remember what you have changed?

No it happened before the upgrade of the CDK, I just run a cdk ls in my CDK project and I got the error. I remember doing some system maintenance around that time, like updating and removing some packages, so I guess something has broken in my system.

Are you able to run cdk ls to list stacks? If not, what's the full error message?

No, I can't run cdk ls, the error is the same

If cdk ls is failing at 2.159.1, do you remember what is your last working version? Can you change back to that version and try again?

Last working version was 2.103.1, I tried reverting to that but no luck, the error is the same.

Please make sure your CDK CLI and lib version are consistent i.e.

Yes they are the same

I tried to run the example CDK in another system and it run without errors. So obviously something has broken in my current system. I also tried to restore the uninstalled packages but I got no luck either. Same error. It seems that I am missing something some dependency but can't figure out what.

I think we can close this issue as it isn't directly related to the project. Thanks for looking @pahud

I will report back if I manage to fix this somehow

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 22, 2024
@pahud
Copy link
Contributor

pahud commented Sep 23, 2024

OK. Closing for now. Feel free to reopen if necessary.

@pahud pahud closed this as completed Sep 23, 2024
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
aws-cdk-lib Related to the aws-cdk-lib package bug This issue is a bug. effort/medium Medium work item – several days of effort p3
Projects
None yet
Development

No branches or pull requests

2 participants