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-lambda-python-alpha): The command "export" does not exist - Poetry #32762

Open
1 task
sltmyr opened this issue Jan 6, 2025 · 6 comments
Open
1 task
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. effort/medium Medium work item – several days of effort p3 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@sltmyr
Copy link

sltmyr commented Jan 6, 2025

Describe the bug

Our python poetry lambda deployments started failing with the error message The command "export" does not exist. I guess this is due to the recent poetry 2.0 release (https://github.com/python-poetry/poetry/releases/tag/2.0.0) that removes the export command and relies on the poetry-plugin-export plugin instead. The issue can be solved by using a custom build image that installs the plugin, this is the Dockerfile that worked for me: https://github.com/aws/aws-cdk/pull/32761/files.

Regression Issue

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

Last Known Working CDK Version

No response

Expected Behavior

Lambda bundling succeeds.

Current Behavior

Bundling fails with The command "export" does not exist

Reproduction Steps

new lambda.PythonLayerVersion(this, "TestLayer", {
  entry: path.join(__dirname, "../layer"),
  description: "Test Lambda Layer with Poetry dependencies",
  compatibleRuntimes: [cdk.aws_lambda.Runtime.PYTHON_3_11],
});

Possible Solution

Install plugin in build image, see https://github.com/aws/aws-cdk/pull/32761/files

Additional Information/Context

No response

CDK CLI Version

2.142.1

Framework Version

No response

Node.js Version

18.0.0

OS

MacOS

Language

TypeScript

Language Version

No response

Other information

No response

@sltmyr sltmyr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 6, 2025
@pahud pahud self-assigned this Jan 7, 2025
@pahud
Copy link
Contributor

pahud commented Jan 7, 2025

Hi

I didn't get it. Where is the export command in your provided sample? Is it in the Dockerfile? If yes, can you share a minimal Dockerfile sample?

new lambda.PythonLayerVersion(this, "TestLayer", {
  entry: path.join(__dirname, "../layer"),
  description: "Test Lambda Layer with Poetry dependencies",
  compatibleRuntimes: [cdk.aws_lambda.Runtime.PYTHON_3_11],
});

And this sounds like an issue from poetry 2.0 and requires a plugin from poetry to work it around?

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

Hey @pahud, please check which version of aws-cdk you're using (not cli, but aws-cdk dependency in your project).

There was fix for installing correct version of poetry during lambda build in
95f8cef#diff-72edaa63ace26f9b6ba27bf4e9420a69f29a4fbe9e574e0c5a1ca269e5b5691a so you need at least version v2.93.0.

In my case I was using older version of aws-cdk where poetry version wasn't locked and with recent release of poetry (v2.0.0) bundling of lambda broke because it installed poetry version 2 where poetry export was dropped.

@sr-rossanderson
Copy link

I'm seeing similar issues in a couple of my AWS codepipelines now. I've not been able to find any way to pin the poetry version being used by the cdk synth command.

Also see this thread:

https://stackoverflow.com/questions/79335563/new-poetry-version-causing-issues-when-running-cdk-diff-due-to-the-aws-image/79338983#79338983

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

pahud commented Jan 8, 2025

Thank you @igorsimko @sr-rossanderson. Looks like this issue is similar to #26823

Let me verify again.

@pahud
Copy link
Contributor

pahud commented Jan 8, 2025

Hi

Looks at this

Looks like current POETRY_VERSION in the vended Dockerfile is 1.5.1. This means when you bundle your layer using the vended Dockerfile, 1.5.1 should be used, rather than 2.0 or above. Can you elaborate on why you are seeing this error?

I am using the 2.174.1 both CLI and lib.

 % npx cdk --version        
2.174.1 (build f353fc7)
hunhsieh@f84d898d8bae issue-triage % grep aws-cdk-lib package.json

    "aws-cdk-lib": "2.174.1",

@pahud
Copy link
Contributor

pahud commented Jan 8, 2025

@igorsimko

There was fix for installing correct version of poetry during lambda build in
95f8cef#diff-72edaa63ace26f9b6ba27bf4e9420a69f29a4fbe9e574e0c5a1ca269e5b5691a so you need at least version v2.93.0.

In my case I was using older version of aws-cdk where poetry version wasn't locked and with recent release of poetry (v2.0.0) bundling of lambda broke because it installed poetry version 2 where poetry export was dropped.

Yes the version pinning starts from 2.93.0 so you can't use 2.0 since then.

image

@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. effort/medium Medium work item – several days of effort p3 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

4 participants