Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sam init fails to deploy a standard sample on Windows platform #7018

Closed
fedor-pavlov opened this issue May 4, 2024 · 3 comments
Closed

sam init fails to deploy a standard sample on Windows platform #7018

fedor-pavlov opened this issue May 4, 2024 · 3 comments
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Comments

@fedor-pavlov
Copy link

Description:

A sam init fails to bootstrap a simple python hello-world template on Windows platform.
You may find this command example in sam init --help and also at https://github.com/aws-samples/cookiecutter-aws-sam-python:

sam init --location gh:aws-samples/cookiecutter-aws-sam-python

this command produces the following error:

'C:\Users\{USER}\AppData\Local\Temp\tmppht_go78' is not recognized as an internal or external command,
operable program or batch file.
2024-05-04 12:11:51 Stopping generation because post_gen_project hook script didn't exit successfully
Error: An error occurred while generating this project : Hook script failed (exit status: 1)

Steps to reproduce:

  1. Run cmd (Win+R, cmd)
  2. Run sam init --location gh:aws-samples/cookiecutter-aws-sam-python
  3. Type in a project name: sam-demo

Observed result:

You've downloaded C:\Users\{USER}\.cookiecutters\cookiecutter-aws-sam-python before. Is it okay to delete and
re-download it? [y/n] (y): y
  [1/2] project_name (Name of the project): sam-demo
  [2/2] include_safe_deployment (n):
'C:\Users\{USER}\AppData\Local\Temp\tmppht_go78' is not recognized as an internal or external command,
operable program or batch file.
2024-05-04 12:11:51 Stopping generation because post_gen_project hook script didn't exit successfully
Error: An error occurred while generating this project : Hook script failed (exit status: 1)

Expected result:

A sample template should be deployed to sam-demo folder.

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

Platform: Windows 11 Enterprise, 22H2, build 22621.3447

  1. OS: Windows 11 Enterprise, 22H2, build 22621.3447
  2. sam --version: SAM CLI, version 1.116.0
  3. AWS region: eu-central-1
# Paste the output of `sam --info` here
{
  "version": "1.116.0",
  "system": {
    "python": "3.11.8",
    "os": "Windows-10-10.0.22621-SP0"
  },
  "additional_dependencies": {
    "docker_engine": "25.0.3",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

D:\code>sam init --debug --location gh:aws-samples/cookiecutter-aws-sam-python
2024-05-04 12:32:51,916 | No config file found in this directory.
2024-05-04 12:32:51,922 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: 'D:\\code\\samconfig.toml'
2024-05-04 12:32:51,926 | Config file location: D:\code\samconfig.toml
2024-05-04 12:32:51,928 | Config file 'D:\code\samconfig.toml' does not exist
2024-05-04 12:32:51,931 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: 'D:\\code\\samconfig.toml'
2024-05-04 12:32:51,934 | Using config file: samconfig.toml, config environment: default
2024-05-04 12:32:51,937 | Expand command line arguments to:
2024-05-04 12:32:51,940 | --location=gh:aws-samples/cookiecutter-aws-sam-python --package_type=Zip --output_dir=.
2024-05-04 12:32:54,309 | Parameters dict created with input given
2024-05-04 12:32:54,311 | {'template': 'gh:aws-samples/cookiecutter-aws-sam-python', 'output_dir': '.', 'no_input': False,
'extra_context': {'architectures': {'value': ['x86_64']}}}
2024-05-04 12:32:54,314 | Baking a new template with cookiecutter with all parameters
You've downloaded C:\Users\{USER}\.cookiecutters\cookiecutter-aws-sam-python before. Is it okay to delete and re-download it? [y/n]
(y):
  [1/2] project_name (Name of the project): sam-demo
  [2/2] include_safe_deployment (n): ,
'C:\Users\{USER}\AppData\Local\Temp\tmppcr4666j' is not recognized as an internal or external command,
operable program or batch file.
2024-05-04 12:33:06 Stopping generation because post_gen_project hook script didn't exit successfully
2024-05-04 12:33:06,028 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2024-05-04 12:33:06,037 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2024-05-04 12:33:06,039 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '55d97f37-4520-4617-a247-2a3567a20d54',
'installationId': 'bd80cbf9-f65d-4e2e-9994-227fa828c739', 'sessionId': '8abc2f0e-e1c8-4006-b545-01ae3f9c58c9', 'executionEnvironment':
'CLI', 'ci': False, 'pyversion': '3.11.8', 'samcliVersion': '1.116.0', 'awsProfileProvided': False, 'debugFlagProvided': True,
'region': '', 'commandName': 'sam init', 'metricSpecificAttributes': {'projectType': 'CFN'}, 'duration': 14093, 'exitReason':
'GenerateProjectFailedError', 'exitCode': 1}}]}
2024-05-04 12:33:06,039 | Unable to find Click Context for getting session_id.
2024-05-04 12:33:06,056 | Sending Telemetry: {'metrics': [{'events': {'requestId': '1d749600-69ae-477d-b6e4-d4f042161188',
'installationId': 'bd80cbf9-f65d-4e2e-9994-227fa828c739', 'sessionId': '8abc2f0e-e1c8-4006-b545-01ae3f9c58c9', 'executionEnvironment':
'CLI', 'ci': False, 'pyversion': '3.11.8', 'samcliVersion': '1.116.0', 'commandName': 'sam init', 'metricSpecificAttributes':
{'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '6aca96ee57164d33b22d768e6372370a',
'time_stamp': '2024-05-04 10:32:51.926', 'exception_name': None}, {'event_name': 'SamConfigFileExtension', 'event_value': '.toml',
'thread_id': 'f7318f23f60b49fe9830e2808ae7407e', 'time_stamp': '2024-05-04 10:32:51.934', 'exception_name': None}]}}}]}
2024-05-04 12:33:07,293 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out.
(read timeout=0.1)
2024-05-04 12:33:07,324 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out.
(read timeout=0.1)
Error: An error occurred while generating this project : Hook script failed (exit status: 1)
@fedor-pavlov fedor-pavlov added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label May 4, 2024
@fedor-pavlov fedor-pavlov changed the title sam init failes to deploy a standard sample on Windows platform sam init fails to deploy a standard sample on Windows platform May 4, 2024
@fedor-pavlov
Copy link
Author

It looks like the error happens in the post_gen_project script which is a part of the https://github.com/aws-samples/cookiecutter-aws-sam-python repository.

@fedor-pavlov
Copy link
Author

Moving this to: aws-samples/cookiecutter-aws-sam-python#47

As a workaround, use sam init without --location option.

@fedor-pavlov fedor-pavlov closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2024
Copy link
Contributor

github-actions bot commented May 4, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

No branches or pull requests

1 participant