question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running sam init fails with 'Error: Please verify your location'

See original GitHub issue

Description

Hi, I have tried debugging this for while.

Originally started in VS Code when trying to create a new SAM application in there, moved the underlying command into terminal to try and debug.

Tried uninstalling and reinstalling SAM, AWS, and git; checking AWS/git credentials, checking windows permissions, running as administrator etc.

I am really stuck as the error message does not contain enough information to work out what is going on and I have never seen anyone else having this error on the internet. The only other person who has ever had ‘Error: Please verify your location’ in relation to AWS SAM, was due to not having git installed, but I do have git installed.

Git works fine across the rest of the system. Can connect to AWS via VS Code and invoke lambdas from there, so credentials seem fine.

When you run it with --location it gives me permission denied, but I have set the permissions on these folders so everyone can access it, and I have no issue in windows explorer.

Provided samples both with and without --location flag.

Thanks!

Steps to reproduce

WITHOUT --LOCATION

Run: $ sam init --debug Params are: 1, 1, blank

WITH --LOCATION

Run: $ sam init --location https://github.com/awslabs/aws-sam-cli-app-templates.git --debug

Observed result

WITHOUT --LOCATION

PS C:\WINDOWS\system32> sam init --debug Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics Which template source would you like to use? 1 - AWS Quick Start Templates 2 - Custom Template Location Choice: 1

Which runtime would you like to use? 1 - nodejs12.x 2 - python3.8 3 - ruby2.7 4 - go1.x 5 - java11 6 - dotnetcore2.1 7 - nodejs10.x 8 - python3.7 9 - python3.6 10 - python2.7 11 - ruby2.5 12 - java8 13 - dotnetcore2.0 14 - dotnetcore1.0 Runtime: 1

Project name [sam-app]:

Cloning app templates from https://github.com/awslabs/aws-sam-cli-app-templates.git

Generating application: Name: sam-app Runtime: nodejs12.x Dependency Manager: npm Application Template: hello-world Output Directory: .

Next steps can be found in the README file at ./sam-app/README.md

Parameters dict created with input given {‘template’: ‘C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\init\templates\cookiecutter-aws-sam-hello-nodejs’, ‘output_dir’: ‘.’, ‘no_input’: True, ‘extra_context’: {‘project_name’: ‘sam-app’, ‘runtime’: ‘nodejs12.x’}} Baking a new template with cookiecutter with all parameters Unable to find cookiecutter.json in the project. Downloading it directly without treating it as a cookiecutter template Downloading project from C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\init\templates\cookiecutter-aws-sam-hello-nodejs to sam-app Sending Telemetry: {‘metrics’: [{‘commandRun’: {‘awsProfileProvided’: False, ‘debugFlagProvided’: True, ‘region’: ‘’, ‘commandName’: ‘sam init’, ‘duration’: 4522, ‘exitReason’: ‘ArbitraryProjectDownloadFailed’, ‘exitCode’: 1, ‘requestId’: ‘ee801dd2-53d2-4f5e-b526-5c946da783eb’, ‘installationId’: ‘2dc4d766-4c3e-4458-a3dc-f80756ef122f’, ‘sessionId’: ‘f5dcb8af-0906-44b8-b160-6722cc8bffda’, ‘executionEnvironment’: ‘CLI’, ‘pyversion’: ‘3.7.6’, ‘samcliVersion’: ‘0.46.1’}}]} HTTPSConnectionPool(host=‘aws-serverless-tools-telemetry.us-west-2.amazonaws.com’, port=443): Read timed out. (read timeout=0.1) Error: Please verify your location. The following types of location are supported:

WITH --LOCATION

PS C:\WINDOWS\system32> sam init --location https://github.com/awslabs/aws-sam-cli-app-templates.git --debug Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics Parameters dict created with input given {‘template’: ‘https://github.com/awslabs/aws-sam-cli-app-templates.git’, ‘output_dir’: ‘.’, ‘no_input’: False} Baking a new template with cookiecutter with all parameters You’ve downloaded C:\Users\c0gnac.cookiecutters\aws-sam-cli-app-templates before. Is it okay to delete and re-download it? [yes]: Unable to find cookiecutter.json in the project. Downloading it directly without treating it as a cookiecutter template Downloading project from https://github.com/awslabs/aws-sam-cli-app-templates.git to . https://github.com/awslabs/aws-sam-cli-app-templates.git location is a source control repository Sending Telemetry: {‘metrics’: [{‘commandRun’: {‘awsProfileProvided’: False, ‘debugFlagProvided’: True, ‘region’: ‘’, ‘commandName’: ‘sam init’, ‘duration’: 7145, ‘exitReason’: ‘PermissionError’, ‘exitCode’: 255, ‘requestId’: ‘c902ee29-b47a-4ca2-a598-f4e952a6ab16’, ‘installationId’: ‘2dc4d766-4c3e-4458-a3dc-f80756ef122f’, ‘sessionId’: ‘9ea6298c-0a0a-4df6-81cb-e34ab49b1311’, ‘executionEnvironment’: ‘CLI’, ‘pyversion’: ‘3.7.6’, ‘samcliVersion’: ‘0.46.1’}}]} HTTPSConnectionPool(host=‘aws-serverless-tools-telemetry.us-west-2.amazonaws.com’, port=443): Read timed out. (read timeout=0.1) Traceback (most recent call last): File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\init_init_.py”, line 80, in generate_project cookiecutter(**params) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\cookiecutter\main.py”, line 63, in cookiecutter password=password File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\cookiecutter\repository.py”, line 122, in determine_repo_dir ‘\n’.join(repository_candidates) cookiecutter.exceptions.RepositoryNotFound: A valid repository for “https://github.com/awslabs/aws-sam-cli-app-templates.git” could not be found in the following locations: C:\Users\c0gnac.cookiecutters\aws-sam-cli-app-templates

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\osutils.py”, line 42, in mkdir_temp yield temp_dir File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\init\arbitrary_project.py”, line 107, in _download_and_copy downloaded_dir = download_fn(clone_to_dir=tempdir) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\cookiecutter\vcs.py”, line 99, in clone stderr=subprocess.STDOUT, File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\subprocess.py”, line 411, in check_output File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\subprocess.py”, line 512, in run subprocess.CalledProcessError: Command '[‘git’, ‘clone’, 'https://github.com/awslabs/aws-sam-cli-app-templates.git’]’ returned non-zero exit status 128.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py”, line 193, in run_module_as_main File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py”, line 85, in run_code File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli_main.py", line 12, in <module> cli(prog_name=“sam”) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py”, line 829, in call return self.main(*args, **kwargs) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py”, line 782, in main rv = self.invoke(ctx) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py”, line 1259, in invoke return process_result(sub_ctx.command.invoke(sub_ctx)) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py”, line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py”, line 610, in invoke return callback(*args, **kwargs) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\decorators.py”, line 73, in new_func return ctx.invoke(f, obj, *args, **kwargs) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py”, line 610, in invoke return callback(*args, **kwargs) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metrics.py”, line 96, in wrapped raise exception # pylint: disable=raising-bad-type File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metrics.py”, line 62, in wrapped return_value = func(*args, **kwargs) File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\init_init.py", line 119, in cli extra_context, File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\init_init.py", line 162, in do_cli do_generate(location, runtime, dependency_manager, output_dir, name, no_input, extra_context) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\init\init_generator.py”, line 12, in do_generate generate_project(location, runtime, dependency_manager, output_dir, name, no_input, extra_context) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\init_init_.py”, line 89, in generate_project generate_non_cookiecutter_project(location=params[“template”], output_dir=project_output_dir) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\init\arbitrary_project.py”, line 81, in generate_non_cookiecutter_project return _download_and_copy(download_fn, output_dir) File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\init\arbitrary_project.py”, line 108, in _download_and_copy osutils.copytree(downloaded_dir, output_dir, ignore=shutil.ignore_patterns(“*.git”)) File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\contextlib.py”, line 130, in exit File “C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\osutils.py”, line 49, in mkdir_temp shutil.rmtree(temp_dir) File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\shutil.py”, line 516, in rmtree File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\shutil.py”, line 395, in _rmtree_unsafe File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\shutil.py”, line 395, in _rmtree_unsafe File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\shutil.py”, line 395, in _rmtree_unsafe [Previous line repeated 1 more time] File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\shutil.py”, line 400, in _rmtree_unsafe File “D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\shutil.py”, line 398, in _rmtree_unsafe PermissionError: [WinError 5] Access is denied: ‘C:\Users\c0gnac\AppData\Local\Temp\tmpbs4_bh0j\aws-sam-cli-app-templates\.git\objects\pack\pack-e4995d8b97945c3793307f4329c28a14d2775e90.idx’

Expected result

Creates new SAM project.

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

  1. OS: Windows 10 v1909 build.18363.720
  2. sam --version: 0.46.1

Happens as a regular user and as an administrator.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:30 (3 by maintainers)

github_iconTop GitHub Comments

18reactions
murashin2012commented, Apr 23, 2020

I came across the same error, and I could solve it making a symbolic link.

Enviroment: ・Windows 10 Version 1809 64bit ・AWS SAM CLI Version 0.47.0

Note the difference at …\samcli\local\ vs …\samcli\lib

Same here. I could solve this problem as follows:

mklink /D “C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\local\init” “C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\init”

Note:

I tried uninstalling the msi and installing via pip and unfortunately I still get the same error.

If your windows is 64 bit, I think you would need to install the AWS SAM CLI 64-bit from the link below as described here “https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-windows.html”:

https://github.com/awslabs/aws-sam-cli/releases/latest/download/AWS_SAM_CLI_64_PY3.msi

Hope this helps.

5reactions
carloserncommented, May 19, 2022

Solved; see below. Caused by invalid default path for cookiecutter templates.

Windows 10 x64 Enterprise aws-cli/1.20.35 (pip installed) sam-cli 1.31.0 (pip installed) Python/3.7.4 botocore/1.21.35

C:\Users\dude\Documents\Projects\x-sc\x-notgit\demo-app>sam init --output-dir .  --name demo-app --debug
2021-10-26 15:11:26,585 | Expand command line arguments to:
2021-10-26 15:11:26,585 | --output_dir=. --name=demo-app --package_type=Zip
2021-10-26 15:11:34,545 |
Cloning from https://github.com/aws/aws-sam-cli-app-templates
    -----------------------
    Generating application:
    -----------------------
    Name: demo-app
    Base Image: amazon/nodejs12.x-base
    Dependency Manager: npm
    Output Directory: .

2021-10-26 15:11:35,078 | Parameters dict created with input given
2021-10-26 15:11:35,079 | {'template': 'c:\\users\\dude\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\samcli\\lib\\init\\image_templates\\nodejs12.x\\cookiecutter-aws-sam-hello-nodejs-lambda-image', 'output_dir': '.', 'no_input': True, 'extra_context': {'project_name': 'demo-app', 'runtime': 'nodejs12.x'}}
2021-10-26 15:11:35,079 | Baking a new template with cookiecutter with all parameters
2021-10-26 15:11:35,080 | Unable to find cookiecutter.json in the project. Downloading it directly without treating it as a cookiecutter template
2021-10-26 15:11:35,080 | Downloading project from c:\users\dude\appdata\local\programs\python\python37-32\lib\site-packages\samcli\lib\init\image_templates\nodejs12.x\cookiecutter-aws-sam-hello-nodejs-lambda-image to demo-app

Error: Please verify your location. The following types of location are supported:

Debug output showing default templates path was invalid:

{'template': 'c:\\users\\dude\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\samcli\\lib\\init\\image_templates\\nodejs12.x\\cookiecutter-aws-sam-hello-nodejs-lambda-image'

The templates were actually located under init\templates, not init\image-templates\nodejs12.x,

c:\users\dude\appdata\local\programs\python\python37-32\lib\site-packages\samcli\lib\init\templates\cookiecutter-aws-sam-hello-nodejs

Ran again with --location parameter with the correct template path, bye bye error 😃

sam init --output-dir . --name demo-app --location c:/users/dude/appdata/local/programs/python/python37-32/lib/site-packages/samcli/lib/init/templates/cookiecutter-aws-sam-hello-nodejs --debug

Same issue here. SAM CLI 1.50.0 Python 3.10.4

It’s works with --location parameter

Read more comments on GitHub >

github_iconTop Results From Across the Web

sam init - AWS Serverless Application Model
Initializes a serverless application with an AWS SAM template. The template provides a folder structure for your AWS Lambda functions, and is connected...
Read more >
Meet AWS SAM CLI: sam init - Medium
This command can initialize a boilerplate serverless app. If you want to create your own template as well as use a custom location...
Read more >
Deploying AWS Lambda "Hello World" using sam init, sam ...
1 Answer 1 · Confirm changes before deploy [y/N]:y. · Allow SAM CLI IAM role creation [Y/n]:y · Disable rollback [y/N]:n · Save...
Read more >
Tutorial: Deploying a Hello World application - 亚马逊云科技
Amazon SAM CLI error: "Failed to create managed resources: Unable to locate credentials" ... This means that you have not set up Amazon...
Read more >
AWS SAM CLI Cheatsheet!. A quick cheat sheet for your friend…
$ sam publish → Publish an AWS SAM application to the AWS Serverless Application Repository. $ sam validate → Verifies whether an AWS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found