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) [email protected]:user/repo.git For Git repositories, you must use location of the root of the repository.
-
Mercurial: hg+ssh://[email protected]/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
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.
Interesting, this issue should have been solved some time ago. I wonder if this some case we are missing out on now.
I am experiencing this as well, same scenario and messages. Totally new environment.
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.
Update, I uninstalled the msi package and used the pip install method and I was able to get up and running.
I tried uninstalling the msi and installing via pip and unfortunately I still get the same error.
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.
I created the symlink above in cmd and it works now!
Also I made sure I was using the msi version and not the pip version of the AWS CLI.
Thanks @murashin2012 for the fix, and thanks everyone else for contributions.
Hi all, I have the same issue and can't create the link because I'm not admin on my company's workstation.
Can you suggest me some other workaround? Maybe skip the sam init step by cloning the templates repo directly?
Thanks!
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.
Im seeing this issue with: sam init 1 - AWS Quick Start Templates 5 - java11 2 - gradle sam-app 4 - Step Functions Sample App (Stock Trader): Gradle Region: us-east-1 Schema: 1 - aws.athena@AthenaQueryStateChange
Generating application:
Name: sam-app Runtime: java11 Dependency Manager: gradle Application Template: step-functions-sample-app Output Directory: .
Next steps can be found in the README file at ./sam-app/README.md
Error: Please verify your location. The following types of location are supported:
- Github: gh:user/repo (or) https://github.com/user/repo (or) [email protected]:user/repo.git For Git repositories, you must use location of the root of the repository.
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 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.
I tried this, but i got 'Access Denied', what do i do?
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.I tried this, but i got 'Access Denied', what do i do?
running command prompt as administrator solved this issue for me. incase there's anyone with similar problem
Tried with @boyersnet method to resolve the template from "lib" folder but the templates were limited. Got mine issue sorted by connecting outside of corporate network when doing "sam init"
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.
TY I created the direcotry and copied the content and it also worked
Is this issue still occurring?
sam init should pull in templates from aws-sam-cli-app-templates repo. the templates that are present within SAM CLI are purely fallback are not exhaustive.
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.I tried this, but i got 'Access Denied', what do i do?
Start a command window (cmd) with administrator permissions.
I had this issue using sam init, though my error did not include the bits right after Parameters dict created with input given [...]
The fix was to install the git cli with brew install git
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
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, 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-nodejsRan again with
--locationparameter 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
@raffian Thanks a ton for this mate. Was initially confused as there were no image folder. They have to fix this issue as well.