aws-sam-cli: Running sam init fails with 'Error: Please verify your location'
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:
-
Github: gh:user/repo (or) https://github.com/user/repo (or) git@github.com:user/repo.git For Git repositories, you must use location of the root of the repository.
-
Mercurial: hg+ssh://hg@bitbucket.org/repo
-
Http(s): https://example.com/code.zip
-
Local Path: /path/to/code.zip
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)
- OS: Windows 10 v1909 build.18363.720
sam --version
: 0.46.1
Happens as a regular user and as an administrator.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 32 (5 by maintainers)
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
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:
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.
Same issue here. SAM CLI 1.50.0 Python 3.10.4
It’s works with --location parameter
Thanks @murashin2012 although mklink was not a known command for me, a little copy did the trick for me.
Copy-Item "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\init" "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\local" -Recurse
Very annoying this is still an issue 2 months later.
@raffian Thanks a ton for this mate. Was initially confused as there were no image folder. They have to fix this issue as well.
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
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
, notinit\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
Don’t know if anyone else has noticed, but the path in Windows has a space that causes the location to bomb: See “AWS SAM” here.
C:\Users[my username]\AppData\Roaming\AWS SAM\aws-sam-cli-app-templates\python3.9\cookiecutter-aws-sam-hello-python
By calling the --location arg and puting the full path in double quotes it works…
sam init --location “C:\Users[my username]\AppData\Roaming\AWS SAM\aws-sam-cli-app-templates\python3.9\cookiecutter-aws-sam-hello-python”
Same issue with SAM CLI, version 1.0.0 on Windows 10 Enterprise. I tried with installation via pip and MSI. Problem remains.
As @boyersnet mentioned, the issue is the path from where SAM CLI tries to copy the template code. It tries to copy from a non-existing ‘local’ folder:
C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\init\templates\...
… but the template is in:
C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\init\templates\...
I was able to get around the issue by creating a symbolic link as suggested by @murashin2012.
Same experience with 0.47.0. When running without location parameter and turning debug on I see this output:
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-example
When I look at that path on my local system, there is no init folder in local.
When looking closer at the install directory I found the init folder in this location:
C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\
.Note the difference at
...\samcli\local\
vs...\samcli\lib
I installed with the MSI, but the zip bundle has the same discrepancy.