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

Created on 25 Mar 2020  路  15Comments  路  Source: aws/aws-sam-cli

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\localinit\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\libinit__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\libinit\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
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\commandsinit__init__.py", line 119, in cli
extra_context,
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commandsinit__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\commandsinitinit_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\libinit__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\libinit\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\libinit\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.

areinit platforwindows

Most helpful comment

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

Enviroment:
銉籛indows 10 Version 1809 64bit
銉籄WS 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\localinit" "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\libinit"

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.

All 15 comments

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:
銉籛indows 10 Version 1809 64bit
銉籄WS 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\localinit" "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\libinit"

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:

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisfosterelli picture chrisfosterelli  路  31Comments

matheusmaximo picture matheusmaximo  路  30Comments

kyeljmd picture kyeljmd  路  31Comments

charsleysa picture charsleysa  路  33Comments

alanchavez88 picture alanchavez88  路  53Comments