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 python breaks import of jinja2 module on windows 10 64-bit #5094

Closed
marcelser opened this issue Nov 19, 2019 · 11 comments
Closed

aws_cdk python breaks import of jinja2 module on windows 10 64-bit #5094

marcelser opened this issue Nov 19, 2019 · 11 comments
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/large Large work item – several weeks of effort language/python Related to Python bindings os/windows Related specifically to Windows behavior p2

Comments

@marcelser
Copy link

when loading aws_cdk core it breaks the jinja2 templating module on Windows 10 64-bit

Reproduction Steps

  • create dummy project with "cdk init -l python"
  • import jinja2 module and it errors out on loading with an EOF error

here'a sample

from aws_cdk import core

from jinja2 import Environment, FileSystemLoader

class ClusterTestStack(core.Stack):

    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        # The code that defines your stack goes here

Error Log

    throw err;
    ^

Error: EOF: end of file, read
    at Object.readSync (fs.js:516:3)
    at SyncStdio.readLine (C:\Users\elserm\devenv\git-projects\environment\cdk-scripts\cluster-test\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13314:25)
    at InputOutput.read (C:\Users\elserm\devenv\git-projects\environment\cdk-scripts\cluster-test\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13264:34)
    at KernelHost.run (C:\Users\elserm\devenv\git-projects\environment\cdk-scripts\cluster-test\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7220:32)
    at Immediate.<anonymous> (C:\Users\elserm\devenv\git-projects\environment\cdk-scripts\cluster-test\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7228:37)
    at processImmediate (internal/timers.js:439:21) {
  errno: -4095,
  syscall: 'read',
  code: 'EOF'
}

Environment

  • CLI Version : 1.16.3 (build 8c7f593)
  • Framework Version: 1.16.3
  • OS : Windows 10 64-bit
  • Language : Python 3.7.5 & nodejs 13.1.0

Other

Interestingly when I just run python cli and do:
"import jinja2 or "from jinja2 import Environment" it works perfectly fine. It's just inside cdk where it breaks miserably and only on windows 10 64-bit. It works perfectly fine on a linux machine of my colleague.

I tried everything like cleaning up and reinstalling python, cleaning up and reinstalling nodejs. Deleting npm and pip caches, re-created .env numerous times, nothing fixes this issue, it's really the aws_cdk core that breaks jinja2.


This is 🐛 Bug Report

@marcelser marcelser added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 19, 2019
@SomayaB SomayaB added os/windows Related specifically to Windows behavior contribution/core This is a PR that came from AWS. language/python Related to Python bindings labels Nov 19, 2019
@eladb eladb added the p2 label Nov 20, 2019
@eladb eladb assigned RomainMuller and unassigned eladb Nov 20, 2019
@eladb
Copy link
Contributor

eladb commented Nov 20, 2019

This is a python specific issue

@marcelser
Copy link
Author

This is a python specific issue

Yes, but you support python in cdk so you should fix comptability issues introduced by aws provided python libraries

@eladb
Copy link
Contributor

eladb commented Nov 21, 2019

Absolutely. The reason I noted that was related to our internal assignment. We should definitely look into this!

@garnaat
Copy link
Contributor

garnaat commented Nov 21, 2019

Are you using the virtual environment created by the init template?

@SomayaB SomayaB removed needs-triage This issue or PR still needs to be triaged. contribution/core This is a PR that came from AWS. labels Nov 21, 2019
@marcelser
Copy link
Author

For the actual project where we discovered the issue I have created the virtual env using "python -m venv .env" but I think for this minimal example for the bug ticket I think I used the one from the init template but I can't say for sure anymore. But I think it happens in both cases.

But we must be able to re-create the .env anyhow if me move the folder or use it in linux etc. therefore we don't even save the .env for our project in our gitlab repository. If anyone needs to work with it he/she checks out the cdk code and quickly runs "python -m venv .env", activates the venv and then does "pip install -r requirements.txt" and he should be ready to go.

@RomainMuller
Copy link
Contributor

Would you be able to run your reproduction with the JSII_DEBUG=1 environment variable, and provide the output (in a gist, pastebin, ... -- feel free to redact anything you don't want to share) ?

@seziCZ
Copy link

seziCZ commented Jul 2, 2020

I seem to have hit the same problem when testing with unittest:

from aws_cdk import core
import unittest

class TestClass(unittest.TestCase):
    def test_method(self):
        self.assertTrue(True)

if __name__ == '__main__':
    unittest.main()

Running the snippet (as an administrator under Windows Enterprise 10.0.18363, Build 18363) results in following stack trace (JSII_DEBUG enabled):

(.env) c:\Sources\Aws>python -m unittest
> {"name":"@aws-cdk/cloud-assembly-schema","version":"1.47.0","tarball":"c:\\Sources\\Aws\\.env\\lib\\site-packages\\aws_cdk\\cloud_assembly_schema\\_jsii\\cloud-assembly-schema@1.47.0.jsii.tgz","api":"load"}
[@jsii/kernel] load {
  name: '@aws-cdk/cloud-assembly-schema',
  version: '1.47.0',
  tarball: 'c:\\Sources\\Aws\\.env\\lib\\site-packages\\aws_cdk\\cloud_assembly_schema\\_jsii\\cloud-assembly-schema@1.47.0.jsii.tgz',
  api: 'load'
}
[@jsii/kernel] creating jsii-kernel modules workdir: C:\Users\TOMAS~1.SEZ\AppData\Local\Temp\jsii-kernel-qosnry
< {"ok":{"assembly":"@aws-cdk/cloud-assembly-schema","types":31}}
> {"name":"@aws-cdk/cx-api","version":"1.47.0","tarball":"c:\\Sources\\Aws\\.env\\lib\\site-packages\\aws_cdk\\cx_api\\_jsii\\cx-api@1.47.0.jsii.tgz","api":"load"}
[@jsii/kernel] load {
  name: '@aws-cdk/cx-api',
  version: '1.47.0',
  tarball: 'c:\\Sources\\Aws\\.env\\lib\\site-packages\\aws_cdk\\cx_api\\_jsii\\cx-api@1.47.0.jsii.tgz',
  api: 'load'
}
< {"ok":{"assembly":"@aws-cdk/cx-api","types":25}}
> {"name":"constructs","version":"3.0.4","tarball":"c:\\Sources\\Aws\\.env\\lib\\site-packages\\constructs\\_jsii\\constructs@3.0.4.jsii.tgz","api":"load"}
[@jsii/kernel] load {
  name: 'constructs',
  version: '3.0.4',
  tarball: 'c:\\Sources\\Aws\\.env\\lib\\site-packages\\constructs\\_jsii\\constructs@3.0.4.jsii.tgz',
  api: 'load'
}
< {"ok":{"assembly":"constructs","types":13}}
> {"name":"@aws-cdk/core","version":"1.47.0","tarball":"c:\\Sources\\Aws\\.env\\lib\\site-packages\\aws_cdk\\core\\_jsii\\core@1.47.0.jsii.tgz","api":"load"}
[@jsii/kernel] load {
  name: '@aws-cdk/core',
  version: '1.47.0',
  tarball: 'c:\\Sources\\Aws\\.env\\lib\\site-packages\\aws_cdk\\core\\_jsii\\core@1.47.0.jsii.tgz',
  api: 'load'
}
< {"ok":{"assembly":"@aws-cdk/core","types":156}}
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
[@jsii/kernel] removing install dir C:\Users\TOMAS~1.SEZ\AppData\Local\Temp\jsii-kernel-qosnry

(.env) c:\Sources\Aws>c:\Sources\Aws\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13612
                    throw e;
                    ^

Error: EOF: end of file, read
    at Object.readSync (fs.js:577:3)
    at SyncStdio.readLine (c:\Sources\Aws\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13587:33)
    at InputOutput.read (c:\Sources\Aws\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13537:34)
    at KernelHost.run (c:\Sources\Aws\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7372:32)
    at Immediate.<anonymous> (c:\Sources\Aws\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7380:37)
    at processImmediate (internal/timers.js:456:21) {
  errno: -4095,
  syscall: 'read',
  code: 'EOF'
}

Virtual environment created by the init sample-app template was used, together with dependencies listed in autogenerated requirements.txt:

(.env) c:\Sources\Aws>pip freeze
atomicwrites==1.4.0
attrs==19.3.0
-e c:\sources\aws\aws
aws-cdk.assets==1.47.0
aws-cdk.aws-cloudwatch==1.47.0
aws-cdk.aws-ec2==1.47.0
aws-cdk.aws-events==1.47.0
aws-cdk.aws-iam==1.47.0
aws-cdk.aws-kms==1.47.0
aws-cdk.aws-lambda==1.47.0
aws-cdk.aws-logs==1.47.0
aws-cdk.aws-s3==1.47.0
aws-cdk.aws-s3-assets==1.47.0
aws-cdk.aws-sns==1.47.0
aws-cdk.aws-sns-subscriptions==1.47.0
aws-cdk.aws-sqs==1.47.0
aws-cdk.aws-ssm==1.47.0
aws-cdk.cloud-assembly-schema==1.47.0
aws-cdk.core==1.47.0
aws-cdk.cx-api==1.47.0
aws-cdk.region-info==1.47.0
cattrs==1.0.0
colorama==0.4.3
constructs==3.0.4
jsii==1.7.0
more-itertools==8.4.0
packaging==20.4
pluggy==0.13.1
publication==0.0.3
py==1.9.0
pyparsing==2.4.7
pytest==5.4.3
python-dateutil==2.8.1
six==1.15.0
typing-extensions==3.7.4.2
wcwidth==0.2.5

@RomainMuller RomainMuller added the effort/large Large work item – several weeks of effort label Aug 11, 2020
@laimonassutkus
Copy link

Any news?

@paujim
Copy link

paujim commented Nov 8, 2020

I'm getting this issue without importing jinja2 module. After upgrading to v1.71.0 in windows OS with python 3.8

@RomainMuller
Copy link
Contributor

Yeah, according to my research in #11314, this appears to be related to yet another instance of node standard library having a slightly different behavior on Windows than other platforms (and I do believe this particular instance is definitely a bug in node).

@RomainMuller RomainMuller removed their assignment Jun 21, 2021
@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/large Large work item – several weeks of effort language/python Related to Python bindings os/windows Related specifically to Windows behavior p2
Projects
None yet
Development

No branches or pull requests

8 participants