aws / aws-toolkit-jetbrains

AWS Toolkit for JetBrains - a plugin for interacting with AWS from JetBrains IDEs
https://plugins.jetbrains.com/plugin/11349-aws-toolkit
Apache License 2.0
732 stars 200 forks source link

PyCharm Fail on Debug SAM Hello World #3547

Open guaido79 opened 1 year ago

guaido79 commented 1 year ago

Describe the bug Running Local Debug on unmodified hello world project will throw error:

Invoking app.lambda_handler (python3.9)
Local image is up-to-date
Using local image: public.ecr.aws/lambda/python:3.9-rapid-x86_64.

Mounting /Users/guimagni/dev/workspaces/aws/phyton/LambdaPyhton03/.aws-sam/build/Function as /var/task:ro,delegated inside runtime container
START RequestId: 2a4799b6-4241-45db-9440-ff9c920fbb26 Version: $LATEST
/var/lang/bin/python3.9: can't open file '/tmp/lambci_debug_files/pydevd.py': [Errno 2] No such file or directory
24 Mar 2023 16:28:16,598 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 2 InvokeID=
/var/lang/bin/python3.9: can't open file '/tmp/lambci_debug_files/pydevd.py': [Errno 2] No such file or directory
END RequestId: 0f43c63d-ed06-4e91-9e51-70a4fc324ca6
REPORT RequestId: 0f43c63d-ed06-4e91-9e51-70a4fc324ca6  Init Duration: 0.19 ms  Duration: 38.85 ms  Billed Duration: 39 ms  Memory Size: 128 MB Max Memory Used: 128 MB 

To reproduce python3 --version Python 3.9.6

  1. brew install aws/tap/aws-sam-cli
  2. sam init --runtime python3.9 --dependency-manager pip --app-template hello-world --name HelloWorld
  3. Open Project With PyCharm (But same error creating project from IDE)
  4. Debug The default lambda_handler(event, context):
Screenshot 2023-03-24 alle 17 45 11

Expected behavior The application start and hit the breakpoint in the implementation

Screenshots There is an error:

Screenshot 2023-03-24 alle 17 46 41

Your Environment

Additional context

  1. Already added /Applications/PyCharm.app/ in docker file sharing
  2. If I open the same project with Visual Studio Code it run debug without problem and hit the break point
  3. I do the same operation with IntelliJ Idea with AWS Toolkit, Java or Javascript, and all run without error, hitting breakpoint
  4. I do the same operation with GoLand and all tun without error, hitting breakpoint
rli commented 1 year ago

I am unable to reproduce on a new install of PyCharm Professional 2022.3.3

/var/lang/bin/python3.9: can't open file '/tmp/lambci_debug_files/pydevd.py': [Errno 2] No such file or directory

On Mac, we mount <PYCHARM>/Contents/plugins/python/helpers/pydev into /tmp/lambci_debug_files It seems like pydev isn't in the PyCharm installation for some reason. Have you tried reinstalling PyCharm?

guaido79 commented 1 year ago

I've a fresh new new installation of PyCharm, downloded to the last version.

The files seems to be there:

Screenshot 2023-03-24 alle 20 13 54

It seems that the mount was unsuccessfull.

I've try to delete image from docker causing to build a new one, but still on error.

yratush commented 9 months ago

any updates on this issue? I have the same error

ISimion commented 7 months ago

Do you happen to have any updates on the issue? I am encountering the same error as well.

/var/lang/bin/python3.11: can't open file '/tmp/lambci_debug_files/pydevd.py': [Errno 2] No such file or directory

naamancampbell commented 6 months ago

Workaround for M1 Mac/Rancher Desktop (lima): https://stackoverflow.com/a/77803515/8751739

rumbarum commented 5 months ago

FYI Docker -> Preferences... -> Resources -> File Sharing add /Applications works.

ISimion commented 5 months ago

@rumbarum That is only valid for Docker Desktop, right?

psi09 commented 1 month ago

I got it fixed, by passing --debugger-path /Users/xyz/pydev to SAM CLI local invoke cmd. you may need to check whether pydev is installed, generally in case if PyCharm on MAC it is here at /Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev (PCharm CE) or /Applications/PyCharm CE.app/Contents/plugins/python/helpers/pydev (PyChram professional), however, copy pydev folder to someother location and pass the path to SAM CLI --debugger-path flag.

psi09 commented 1 month ago

@rumbarum That is only valid for Docker Desktop, right?

I'm using Rancher Desktop, works for me if running dockerd as container runtime, so it would be right to say that it may work for Docker Desktop as well..