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
Utku Can
  • 683
  • 3
  • 12

5 Answers5

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)

Yasas Lowe
  • 91
  • 1
  • 6
  • 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](/help/how-to-answer). – Community Jul 26 '22 at 01:31
  • I am very much new to AWS SAM.You are a saviour,thanks :) – Pavithra B Nov 29 '22 at 15:38
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

Utku Can
  • 683
  • 3
  • 12
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

Mehmet Recep Yildiz
  • 1,359
  • 17
  • 14
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

user2148956
  • 179
  • 1
  • 1
  • 10
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