aws-sam-cli: Unable to create Serverless API using SAM v1.40.0

Description:

I tried creating a SAM application using the quick start template for serverless API, but unfortunately it complains that it’s unable to local the quickstart-web template.

Steps to reproduce:

D:\Projects
λ sam init

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: 3

Which runtime would you like to use?
        1 - dotnetcore3.1
        2 - nodejs14.x
        3 - nodejs12.x
        4 - python3.9
        5 - python3.8
Runtime: 2

Based on your selections, the only Package type available is Zip.
We will proceed to selecting the Package type as Zip.

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

Project name [sam-app]: sammy

Cloning from https://github.com/aws/aws-sam-cli-app-templates (process may take a moment)
Error: Can't find application template quick-start-web - check valid values in interactive init.

Observed result:

Error: Can’t find application template quick-start-web - check valid values in interactive init.

Expected result:

I expected it to create Serverless API project with it’s default scaffolding.

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

  1. OS: Windows 10 Pro
  2. sam --version: SAM CLI, version 1.40.0
  3. AWS region: us-east-2

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 22 (7 by maintainers)

Most upvoted comments

This was closed prematurely imo. Latest packaged build for Windows (AWS_SAM_CLI_64_PY3.msi 2022-05-04) still has this issue.

@kamsar Thank you so much! Cloning the repository manually in to the app data directory solved the problem. @jfuss Maybe that’s the problem. SAM cli has some issue cloning to app data directories and can be looked into.

For those who stumble upon the same thing, you can do the following to solve it temporarily:

  1. Open the start menu and type run and open the run command dialog.
  2. Type %APPDATA%\AWS SAM and click OK.
  3. Look for a folder called aws-sam-cli-app-templates
  4. If the folder exists, delete it or if it doesn’t follow the next step.
  5. Open cmd in the current directory and then clone the sam cli templates repository manually. git clone https://github.com/aws/aws-sam-cli-app-templates.git
  6. That’s it! Now try running sam init in your actual workspace directory.

Meanwhile, please refer here for a workaround

I ran into this issue as well. In my case:

  • Only one drive (C:)
  • I had a much older clone of the repository sitting around at %APPDATA%\AWS SAM\aws-sam-cli-app-templates
  • As with @sdsa-cci, the --debug flag gives the generic Clone error message with no further details
  • No HTTP proxies or anything going on - I do have a DNS-layer adblock, possibly from a blocked telemetry call?
  • The user I ran sam as has write access to the %APPDATA%\AWS SAM folder

I was able to fix it by:

  1. Open %APPDATA%\AWS SAM
  2. Delete the aws-sam-cli-app-templates folder
  3. Run git clone https://github.com/aws/aws-sam-cli-app-templates.git to re-populate it

Obviously this does not solve the clone error problem, but it does unblock usage of sam init.

Related issue is been fixed and released in latest 1.53.0 version. Please give it a try and let us know if you still experience similar issues.

Trying to clone the repo manually as described above gives me this error:

PS C:\Users\Nicole\AppData\Roaming\AWS SAM> git clone https://github.com/aws/aws-sam-cli-app-templates.git
Cloning into 'aws-sam-cli-app-templates'...
remote: Enumerating objects: 5561, done.
remote: Counting objects: 100% (1660/1660), done.
remote: Compressing objects: 100% (491/491), done.
remote: Total 5561 (delta 1419), reused 1238 (delta 1164), pack-reused 3901
Receiving objects: 100% (5561/5561), 21.09 MiB | 10.57 MiB/s, done.
Resolving deltas: 100% (3709/3709), done.
fatal: cannot create directory at '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': Filename too long
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

Thankfully I’m making a python Lambda so it isn’t impacting me

EDIT: Spoke to soon - now running into #1891. Wonder if it’s related EDIT 2: Enabled git longpaths system wide and that fixed both issues on my end

I encounter the same scenario when choosing “Serverless API” on the second prompt. I followed the same steps and was resolved. But I think that is not an Ideal fix. I hope that maintainer cloud look what’s wrong with choosing Serverless API

Looks like it’s the same issue as #3946, which was caused by long path limitation in Windows. We have a fix #3950 merged but not released yet