AWS Serverless Application Model init error on Pycharm
Asked Answered
W

5

7

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
Wheelchair answered 1/7, 2022 at 10:6 Comment(0)
W
5

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

Wheelchair answered 2/7, 2022 at 21:1 Comment(0)
L
7

Open PowerShell in admin mode and type this and execute

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

worked for me. (fixes webstorm aws toolkit error in init too)

Labarbera answered 23/7, 2022 at 9:17 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Menstruate
I am very much new to AWS SAM.You are a saviour,thanks :)Shebat
W
5

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

Wheelchair answered 2/7, 2022 at 21:1 Comment(0)
F
1

On my windows machine, I fixed it by setting LongPathsEnabled to 1 in the registery:

  • Open Registry Editor (regedit.exe).

  • Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem

  • Set LongPathsEnabled to 1.

This sets Git to allow long paths

Fulgent answered 6/9, 2022 at 11:8 Comment(0)
T
1

Neither of the solutions worked for me. Instead:

  1. Open Registry Editor (regedit.exe).
  2. Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
  3. Set LongPathsEnabled to 1

Copied from: https://lightrun.com/answers/aws-aws-sam-cli-permissions-error-unstable-state-when-updating-repo

Talaria answered 11/10, 2022 at 20:19 Comment(0)
H
0

Run this in powershell (as admin)

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

works for me

Hagiocracy answered 16/11, 2022 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.