Majestic.cloud

How to fix the sam init error “unstable state when updating repo” on Windows

On some Windows based systems, when you issue the command

sam init

you might get the following error:

Error: Unstable state when updating repo. Check that you have permissions to create/delete files in C:\Users\YOURUSER\AppData\Roaming\AWS SAM directory or file an issue at https://github.com/aws/aws-sam-cli/issues

This happens due to a path limitation on Windows and it’s easy to fix. Just go and open PowerShell as Adminstrator and run the following command

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