Search code examples
amazon-web-servicespycharmaws-samaws-sam-cli

AWS Serverless Application Model init error on Pycharm


I am trying to create a new AWS Serverless Application on Pycharm but i am getting this error:

Could not execute `sam init`!: [Cloning from https://github.com/aws/aws-sam-cli-app-templates (process may take a moment),
Error: Unstable state when updating repo. Check that you have permissions to create/delete files

How can i solve this problem ?

Details:

OS:Windows 10 , x64
Version: Python 3.9, SAM CLI- 1.53.0
IDE: Pycharm 2022.1.3 Pro Edition
Git Version 2.37

Solution

  • Okay here is the problem why it occurs and the solution for Windows users:

    The problem was with the path ("AWS SAM") in Windows that has a space causes the problem: By calling the --location arg and puting the full path in double quotes it works

    sam init --location "C:\Users[your_user_name]\AppData\Roaming\AWS SAM\aws-sam-cli-app-templates\python3.9\cookiecutter-aws-sam-hello-python"

    Ref: https://github.com/aws/aws-sam-cli/issues/1891

    Thanks to:

    https://github.com/hawflau

    https://github.com/john-zenden