aws-sam-cli: sam init quickstart templates failing on windows

Description:

sam init {{ any flags }}

will fail with fresh installs on windows. I can replicate with defaults or a smattering of various options. (For reference, I’m trying to create a node16.x project Hello World project).

I have SAM and AWS CLI installed on a fresh windows 11 machine. I can replicate the issue with identical output with a fresh install of both CLIs on a windows 10 machine. The CLI will make it through all interactive prompts or flags properly, but throw an error when actually creating the project locally. I can repro the problem in command prompt or Powershell (PSCore 7.x) .The non-verbose error is

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

Steps to reproduce:

  • Start with clean (No AWS products installed) install of Windows 11 (the issue seems to effect windows 10 too so dealers choice).
  • Ensure python and git are installed
  • Install latest AWS CLI and SAM CLI from their respective MSIs, pulled from the getting started docs.
  • Create a fresh AWS account, create a user with the generic Admin role. Create CLI credentials for this user. (not sure much of this matters but this is what I did) (Enable MFA on the root user, do more best practices etc etc etc).
  • Run aws configure using the aforementioned access keys
  • create a blank directory and cd into it
  • run sam init -> quickstart templates -> option 10 for node 16 -> option 1 for zip -> option 1 for not typescript. -> No to Xray -> default app name (Not sure if it makes a difference but I did have docker desktop installed and running, I tried this with image deployments too. Same results)

Observed result:

PS C:\Users\taran\SAM> sam init --debug
2022-07-02 16:50:13,858 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-07-02 16:50:13,858 | Using config file: samconfig.toml, config environment: default
2022-07-02 16:50:13,858 | Expand command line arguments to:
2022-07-02 16:50:13,858 | --package_type=Zip --output_dir=.

You can preselect a particular runtime or package type when using the `sam init` experience.
Call `sam init --help` to learn more.

Which template source would you like to use?
        1 - AWS Quick Start Templates
        2 - Custom Template Location
Choice: 1

Choose an AWS Quick Start application template
        1 - Hello World Example
        2 - Multi-step workflow
        3 - Serverless API
        4 - Scheduled task
        5 - Standalone function
        6 - Data processing
        7 - Infrastructure event management
        8 - Machine Learning
Template: 1

Use the most popular runtime and package type? (Python and zip) [y/N]: N

Which runtime would you like to use?
        1 - dotnet6
        2 - dotnet5.0
        3 - dotnetcore3.1
        4 - go1.x
        5 - graalvm.java11 (provided.al2)
        6 - graalvm.java17 (provided.al2)
        7 - java11
        8 - java8.al2
        9 - java8
        10 - nodejs16.x
        11 - nodejs14.x
        12 - nodejs12.x
        13 - python3.9
        14 - python3.8
        15 - python3.7
        16 - python3.6
        17 - ruby2.7
        18 - rust (provided.al2)
Runtime: 10

What package type would you like to use?
        1 - Zip
        2 - Image
Package type: 1

Based on your selections, the only dependency manager available is npm.
We will proceed copying the template using npm.

Select your starter template
        1 - Hello World Example
        2 - Hello World Example TypeScript
Template: 1

Would you like to enable X-Ray tracing on the function(s) in your application?  [y/N]: N

Project name [sam-app]:
2022-07-02 16:50:32,915 |
Cloning from https://github.com/aws/aws-sam-cli-app-templates (process may take a moment)
2022-07-02 16:50:32,916 | Configure core.longpaths=true in git clone. You might also need to enable long paths in Windows registry.
2022-07-02 16:50:44,289 | Removing old repo at C:\Users\taran\AppData\Roaming\AWS SAM\aws-sam-cli-app-templates
2022-07-02 16:50:45,685 | Copying from C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates to C:\Users\taran\AppData\Roaming\AWS SAM\aws-sam-cli-app-templates
2022-07-02 16:50:52,140 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-core, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219940>)
2022-07-02 16:50:52,140 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-core, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219940>)
2022-07-02 16:50:52,140 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-events, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219940>)
2022-07-02 16:50:52,141 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-events, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219940>)
2022-07-02 16:50:52,141 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-runtime-interface-client, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219940>)
2022-07-02 16:50:52,141 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-runtime-interface-client, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219940>)
2022-07-02 16:50:52,142 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-serialization, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219940>)
2022-07-02 16:50:52,142 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-serialization, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219940>)
2022-07-02 16:50:52,143 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219940>)
2022-07-02 16:50:52,144 | rmtree failed in <built-in function unlink> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\helloworld\native-image.properties, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219900>)
2022-07-02 16:50:52,146 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\helloworld, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219900>)
2022-07-02 16:50:52,147 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A2198C0>)
2022-07-02 16:50:52,148 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,149 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A2197C0>)
2022-07-02 16:50:52,150 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219780>)
2022-07-02 16:50:52,152 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219600>)
2022-07-02 16:50:52,153 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A2195C0>)
2022-07-02 16:50:52,156 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219500>)
2022-07-02 16:50:52,157 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-gradle, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A2192C0>)
2022-07-02 16:50:52,164 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-core, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,166 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-core, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,166 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-events, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,166 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-events, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,167 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-runtime-interface-client, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,167 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-runtime-interface-client, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,167 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-serialization, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,167 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-serialization, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,168 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,170 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219740>)
2022-07-02 16:50:52,171 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A2196C0>)
2022-07-02 16:50:52,172 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219780>)
2022-07-02 16:50:52,173 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219640>)
2022-07-02 16:50:52,177 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A2194C0>)
2022-07-02 16:50:52,179 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219480>)
2022-07-02 16:50:52,182 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219380>)
2022-07-02 16:50:52,183 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11\cookiecutter-aws-sam-graalvm-maven, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219300>)
2022-07-02 16:50:52,185 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java11, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A005EC0>)
2022-07-02 16:50:52,194 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-core, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219980>)
2022-07-02 16:50:52,195 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-core, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219980>)
2022-07-02 16:50:52,195 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-events, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219980>)
2022-07-02 16:50:52,196 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-events, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219980>)
2022-07-02 16:50:52,196 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-runtime-interface-client, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219980>)
2022-07-02 16:50:52,196 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-runtime-interface-client, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219980>)
2022-07-02 16:50:52,196 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-serialization, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219980>)
2022-07-02 16:50:52,197 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-serialization, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219980>)
2022-07-02 16:50:52,198 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219980>)
2022-07-02 16:50:52,198 | rmtree failed in <built-in function unlink> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\helloworld\native-image.properties, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219840>)
2022-07-02 16:50:52,200 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\helloworld, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219840>)
2022-07-02 16:50:52,201 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219900>)
2022-07-02 16:50:52,202 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,202 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219700>)
2022-07-02 16:50:52,203 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src\main, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219740>)
2022-07-02 16:50:52,206 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction\src, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219780>)
2022-07-02 16:50:52,207 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}\HelloWorldFunction, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219640>)
2022-07-02 16:50:52,209 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle\{{cookiecutter.project_name}}, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219440>)
2022-07-02 16:50:52,210 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-gradle, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219200>)
2022-07-02 16:50:52,218 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-core, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,219 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-core, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,220 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-events, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,220 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-events, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,220 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-runtime-interface-client, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,221 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-runtime-interface-client, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,221 | rmtree failed in <built-in function scandir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-serialization, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,221 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws\aws-lambda-java-serialization, details: (<class 'FileNotFoundError'>, FileNotFoundError(2, 'The system cannot find the path specified'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,222 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image\com.amazonaws, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219880>)
2022-07-02 16:50:52,224 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF\native-image, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A2196C0>)
2022-07-02 16:50:52,225 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources\META-INF, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219680>)
2022-07-02 16:50:52,226 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main\resources, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219740>)
2022-07-02 16:50:52,227 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src\main, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219540>)
2022-07-02 16:50:52,230 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction\src, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A2194C0>)
2022-07-02 16:50:52,231 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}\HelloWorldFunction, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219400>)
2022-07-02 16:50:52,233 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven\{{cookiecutter.project_name}}, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A219380>)
2022-07-02 16:50:52,234 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17\cookiecutter-aws-sam-graalvm-maven, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A2191C0>)
2022-07-02 16:50:52,236 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm\java17, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A005EC0>)
2022-07-02 16:50:52,237 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2\graalvm, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A005F00>)
2022-07-02 16:50:52,241 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates\provided.al2, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A005F40>)
2022-07-02 16:50:52,563 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls\aws-sam-cli-app-templates, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E6A005E00>)
2022-07-02 16:50:52,564 | rmtree failed in <built-in function rmdir> for C:\Users\taran\AppData\Local\Temp\tmpkn0ngyls, details: (<class 'OSError'>, OSError(41, 'The directory is not empty'), <traceback object at 0x0000021E69FE8100>)
2022-07-02 16:50:52,565 | Template is not provided in context, skip adding project type metric
2022-07-02 16:50:52,566 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '4051ee11-2e95-423d-ab51-2d657db33725', 'installationId': 'eda45204-2efc-44cd-b956-ac7563effaad', 'sessionId': '5840cdc0-ce22-4ebb-a35a-18419c48e119', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.53.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam init', 'duration': 38708, 'exitReason': 'AppTemplateUpdateException', 'exitCode': 1}}]}
2022-07-02 16:50:53,150 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: Unstable state when updating repo. Check that you have permissions to create/delete files in C:\Users\taran\AppData\Roaming\AWS SAM directory or file an issue at https://github.com/aws/aws-sam-cli/issues
PS C:\Users\taran\SAM>

Expected result:

No errors, fresh SAM template fun

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: WIndows 11 OS Build 22000.739
  2. sam --version: 1.53.0
  3. AWS region: us-east-1

AWS CLI version: 2.7.12 git for windows 2.37.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 18 (5 by maintainers)

Most upvoted comments

This is work for me Open the Powershell as administrator then type:

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

@gmarshall56 Look through this thread… You need to run this in Powershell:

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

Hi @RickardTaran @Rishiv15 can you please follow here to opt in to remove the MAX_PATH limitation? That should remove the errors.

@RickardTaran @john-zenden thanks for suggestions. We will look into if we can do something with the registry through MSI.

The documentation update should be something that we can do relatively sooner.

facing the same issue