aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.52k stars 1.17k forks source link

Bug: sam build - OSError #6943

Closed j0y0nt closed 2 months ago

j0y0nt commented 7 months ago

Description:

Command sam build --use-container failed on my windows 11 machine. I was expecting the build step to complete successfully, so that I can run full stack sample app in local environment.

Steps to reproduce:

  1. Use windows 11 machine.
  2. Follow the steps as mentioned below.

PS C:\projects> mkdir samy2

Directory: C:\projects

Mode LastWriteTime Length Name


d----- 12-04-2024 13:47 samy2

PS C:\projects> cd .\samy2\ PS C:\projects\samy2> sam init

You can preselect a particular runtime or package type when using the sam init experience. Call sam init --help to learn more.

Which template source would you like to use? 1 - AWS Quick Start Templates 2 - Custom Template Location Choice: 1

Choose an AWS Quick Start application template 1 - Hello World Example 2 - Data processing 3 - Hello World Example with Powertools for AWS Lambda 4 - Multi-step workflow 5 - Scheduled task 6 - Standalone function 7 - Serverless API 8 - Infrastructure event management 9 - Lambda Response Streaming 10 - Serverless Connector Hello World Example 11 - Multi-step workflow with Connectors 12 - GraphQLApi Hello World Example 13 - Full Stack 14 - Lambda EFS example 15 - DynamoDB Example 16 - Machine Learning Template: 13

Which runtime would you like to use? 1 - nodejs20.x 2 - nodejs18.x Runtime: 1

Based on your selections, the only Package type available is Zip. We will proceed to selecting the Package type as Zip.

Based on your selections, the only dependency manager available is npm. We will proceed copying the template using npm.

Would you like to enable X-Ray tracing on the function(s) in your application? [y/N]: N

Would you like to enable monitoring using CloudWatch Application Insights? For more info, please view https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-application-insights.html [y/N]: N

Would you like to set Structured Logging in JSON format on your Lambda functions? [y/N]: y Structured Logging in JSON format might incur an additional cost. View https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-pricing for more details

Project name [sam-app]: fs-app

-----------------------
Generating application:
-----------------------
Name: fs-app
Runtime: nodejs20.x
Architectures: x86_64
Dependency Manager: npm
Application Template: quick-start-full-stack
Output Directory: .
Configuration file: fs-app\samconfig.toml

Next steps can be found in the README file at fs-app\README.md

Commands you can use next

[] Create pipeline: cd fs-app && sam pipeline init --bootstrap [] Validate SAM template: cd fs-app && sam validate [*] Test Function in the Cloud: cd fs-app && sam sync --stack-name {stack-name} --watch

Warning: Unable to add LoggingConfig to the project. To learn more about LoggingConfig visit {self.DOC_LINK} PS C:\projects\samy2> cd .\fs-app\ PS C:\projects\samy2\fs-app> tree . Folder PATH listing for volume OS Volume serial number is 625A-A8DD C:\PROJECTS\SAMY2\FS-APP ├───backend │ ├───src │ │ └───handlers │ └───tests │ └───unit │ └───handlers ├───events └───frontend ├───public ├───src │ └───components └───test PS C:\projects\samy2\fs-app> code . PS C:\projects\samy2\fs-app> sam build --use-container Error: Failed to parse template: while parsing a flow node expected the node content, but found ':' in "", line 161, column 19: :distribution/, !Ref CloudFrontD ... ^ PS C:\projects\samy2\fs-app> sam build --use-container Starting Build use cache Starting Build inside a container Cache is invalid, running build and copying resources for following functions (getAllItemsFunction, getByIdFunction, putItemFunction) Building codeuri: C:\projects\samy2\fs-app\backend runtime: nodejs20.x metadata: {} architecture: x86_64 functions: getAllItemsFunction, getByIdFunction, putItemFunction

Fetching public.ecr.aws/sam/build-nodejs20.x:latest-x86_64 Docker container image........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ Mounting C:\projects\samy2\fs-app\backend as /tmp/samcli/source:ro,delegated, inside runtime container

Error: [Errno 22] Invalid argument: 'C:\projects\samy2\fs-app\.aws-sam\build\getAllItemsFunction\node_modules\.bin\fxparser' Traceback: File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\cli\cli_config_file.py", line 347, in wrapper return func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\decorators.py", line 92, in new_func return ctx.invoke(f, obj, *args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\telemetry\metric.py", line 185, in wrapped raise exception # pylint: disable=raising-bad-type ^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\telemetry\metric.py", line 150, in wrapped return_value = func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\version_checker.py", line 43, in wrapped actual_result = func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\cli\main.py", line 95, in wrapper return func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\commands\build\command.py", line 175, in cli do_cli( File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\commands\build\command.py", line 264, in do_cli ctx.run() File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\commands\build\build_context.py", line 284, in run self._build_result = builder.build() ^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\app_builder.py", line 225, in build return ApplicationBuildResult(build_graph, build_strategy.build()) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 413, in build return super().build() ^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 83, in build result.update(self._build_functions(self._build_graph)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 419, in _build_functions return self._run_builds_async( ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 435, in _run_builds_async async_results = async_context.run_async() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\async_utils.py", line 137, in run_async return run_given_tasks_async(self._async_tasks, event_loop) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\async_utils.py", line 96, in run_given_tasks_async return event_loop.run_until_complete(_run_given_tasks_async(tasks, event_loop, executor)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "asyncio\base_events.py", line 654, in run_until_complete File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\async_utils.py", line 62, in _run_given_tasks_async raise result File "concurrent\futures\thread.py", line 58, in run File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 446, in build_single_function_definition return self._delegate_build_strategy.build_single_function_definition(build_definition) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 592, in build_single_function_definition return self._cached_build_strategy.build_single_function_definition(build_definition) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 300, in build_single_function_definition build_result = self._delegate_build_strategy.build_single_function_definition(build_definition) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 197, in build_single_function_definition osutils.copytree(single_build_dir, artifacts_dir) File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\osutils.py", line 180, in copytree copytree(new_source, new_destination, ignore=ignore) File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\osutils.py", line 180, in copytree copytree(new_source, new_destination, ignore=ignore) File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\osutils.py", line 182, in copytree shutil.copy2(new_source, new_destination) File "shutil.py", line 448, in copy2 File "shutil.py", line 256, in copyfile

An unexpected error was encountered while executing "sam build". Search for an existing issue: https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20build%20-%20OSError Or create a bug report: https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20OSError Running NodejsNpmBuilder:NpmPack Running NodejsNpmBuilder:CopyNpmrcAndLockfile Running NodejsNpmBuilder:CopySource Running NodejsNpmBuilder:NpmInstall Running NodejsNpmBuilder:CleanUpNpmrc Running NodejsNpmBuilder:LockfileCleanUp PS C:\projects\samy2\fs-app>

Observed result:

PS C:\projects\samy2\fs-app> sam build --use-container --debug 2024-04-12 14:15:09,255 | Config file location: C:\projects\samy2\fs-app\samconfig.toml 2024-04-12 14:15:09,255 | Loading configuration values from [default.['build'].parameters] (env.command_name.section) in config file at 'C:\projects\samy2\fs-app\samconfig.toml'... 2024-04-12 14:15:09,255 | Configuration values successfully loaded. 2024-04-12 14:15:09,255 | Configuration values are: {'stack_name': 'fs-app', 'cached': True, 'parallel': True} 2024-04-12 14:15:09,271 | Using SAM Template at C:\projects\samy2\fs-app\template.yaml 2024-04-12 14:15:09,304 | Using config file: samconfig.toml, config environment: default 2024-04-12 14:15:09,304 | Expand command line arguments to: 2024-04-12 14:15:09,304 | --template_file=C:\projects\samy2\fs-app\template.yaml --use_container --parallel --mount_with=READ --build_dir=.aws-sam\build --cache_dir=.aws-sam\cache --cached 2024-04-12 14:15:09,429 | 'build' command is called 2024-04-12 14:15:09,429 | Starting Build use cache 2024-04-12 14:15:09,429 | Starting Build inside a container 2024-04-12 14:15:09,444 | No Parameters detected in the template 2024-04-12 14:15:09,478 | There is no customer defined id or cdk path defined for resource ApiGatewayApi, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,478 | There is no customer defined id or cdk path defined for resource getAllItemsFunction, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,478 | There is no customer defined id or cdk path defined for resource getByIdFunction, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,478 | There is no customer defined id or cdk path defined for resource putItemFunction, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,478 | There is no customer defined id or cdk path defined for resource SampleTable, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,478 | There is no customer defined id or cdk path defined for resource WebSiteBucket, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,478 | There is no customer defined id or cdk path defined for resource WebSiteBucketPolicy, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,478 | There is no customer defined id or cdk path defined for resource CloudFrontDistribution, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,478 | There is no customer defined id or cdk path defined for resource CloudFrontOriginAccessControl, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,493 | Unable to resolve property DomainName: {'Fn::GetAtt': ['WebSiteBucket', 'RegionalDomainName']}. Leaving as is. 2024-04-12 14:15:09,493 | Unable to resolve property OriginAccessControlId: {'Fn::GetAtt': ['CloudFrontOriginAccessControl', 'Id']}. Leaving as is. 2024-04-12 14:15:09,493 | Unable to resolve property Value: {'Fn::GetAtt': ['CloudFrontDistribution', 'DomainName']}. Leaving as is. 2024-04-12 14:15:09,493 | 0 stacks found in the template 2024-04-12 14:15:09,493 | No Parameters detected in the template 2024-04-12 14:15:09,507 | There is no customer defined id or cdk path defined for resource ApiGatewayApi, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,507 | There is no customer defined id or cdk path defined for resource getAllItemsFunction, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,507 | There is no customer defined id or cdk path defined for resource getByIdFunction, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,507 | There is no customer defined id or cdk path defined for resource putItemFunction, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,507 | There is no customer defined id or cdk path defined for resource SampleTable, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,523 | There is no customer defined id or cdk path defined for resource WebSiteBucket, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,523 | There is no customer defined id or cdk path defined for resource WebSiteBucketPolicy, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,523 | There is no customer defined id or cdk path defined for resource CloudFrontDistribution, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,523 | There is no customer defined id or cdk path defined for resource CloudFrontOriginAccessControl, so we will use the resource logical id as the resource id 2024-04-12 14:15:09,523 | Unable to resolve property DomainName: {'Fn::GetAtt': ['WebSiteBucket', 'RegionalDomainName']}. Leaving as is. 2024-04-12 14:15:09,523 | Unable to resolve property OriginAccessControlId: {'Fn::GetAtt': ['CloudFrontOriginAccessControl', 'Id']}. Leaving as is. 2024-04-12 14:15:09,523 | Unable to resolve property Value: {'Fn::GetAtt': ['CloudFrontDistribution', 'DomainName']}. Leaving as is. 2024-04-12 14:15:09,523 | 9 resources found in the stack 2024-04-12 14:15:09,523 | Found Serverless function with name='getAllItemsFunction' and CodeUri='backend/' 2024-04-12 14:15:09,539 | --base-dir is not presented, adjusting uri backend/ relative to C:\projects\samy2\fs-app\template.yaml 2024-04-12 14:15:09,539 | Found Serverless function with name='getByIdFunction' and CodeUri='backend/' 2024-04-12 14:15:09,539 | --base-dir is not presented, adjusting uri backend/ relative to C:\projects\samy2\fs-app\template.yaml 2024-04-12 14:15:09,543 | Found Serverless function with name='putItemFunction' and CodeUri='backend/' 2024-04-12 14:15:09,543 | --base-dir is not presented, adjusting uri backend/ relative to C:\projects\samy2\fs-app\template.yaml 2024-04-12 14:15:10,180 | 9 resources found in the stack 2024-04-12 14:15:10,180 | Found Serverless function with name='getAllItemsFunction' and CodeUri='backend/' 2024-04-12 14:15:10,180 | Found Serverless function with name='getByIdFunction' and CodeUri='backend/' 2024-04-12 14:15:10,180 | Found Serverless function with name='putItemFunction' and CodeUri='backend/' 2024-04-12 14:15:10,180 | Instantiating build definitions 2024-04-12 14:15:10,205 | Same function build definition found, adding function (Previous: BuildDefinition(nodejs20.x, C:\projects\samy2\fs-app\backend, Zip, , 6768ead7-660d-4d84-8b76-3e78da80f273, {}, {}, x86_64, []), Current: BuildDefinition(nodejs20.x, C:\projects\samy2\fs-app\backend, Zip, , e5dfcb1e-a19b-4a94-9456-64a14f796bbb, {}, {}, x86_64, []), Function: Function(function_id='getAllItemsFunction', name='getAllItemsFunction', functionname='getAllItemsFunction', runtime='nodejs20.x', memory=128, timeout=100, handler='src/handlers/get-all-items.getAllItemsHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='C:\projects\samy2\fs-app\backend', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable', 'ENDPOINT_OVERRIDE': ''}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'GET', 'RestApiId': 'ApiGatewayApi'}}}, metadata={'SamResourceId': 'getAllItemsFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None, function_build_info=<FunctionBuildInfo.BuildableZip: ('BuildableZip', 'Regular ZIP function which can be build with SAM CLI')>, stack_path='', runtime_management_config=None, logging_config={'LogFormat': 'JSON'})) 2024-04-12 14:15:10,212 | Same function build definition found, adding function (Previous: BuildDefinition(nodejs20.x, C:\projects\samy2\fs-app\backend, Zip, , 6768ead7-660d-4d84-8b76-3e78da80f273, {}, {}, x86_64, ['getAllItemsFunction']), Current: BuildDefinition(nodejs20.x, C:\projects\samy2\fs-app\backend, Zip, , d003c1ee-8513-4097-baad-8e2766cdeda9, {}, {}, x86_64, []), Function: Function(function_id='getByIdFunction', name='getByIdFunction', functionname='getByIdFunction', runtime='nodejs20.x', memory=128, timeout=100, handler='src/handlers/get-by-id.getByIdHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='C:\projects\samy2\fs-app\backend', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable', 'ENDPOINT_OVERRIDE': ''}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/{id}', 'Method': 'GET', 'RestApiId': 'ApiGatewayApi'}}}, metadata={'SamResourceId': 'getByIdFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None, function_build_info=<FunctionBuildInfo.BuildableZip: ('BuildableZip', 'Regular ZIP function which can be build with SAM CLI')>, stack_path='', runtime_management_config=None, logging_config={'LogFormat': 'JSON'})) 2024-04-12 14:15:10,212 | Same function build definition found, adding function (Previous: BuildDefinition(nodejs20.x, C:\projects\samy2\fs-app\backend, Zip, , 6768ead7-660d-4d84-8b76-3e78da80f273, {}, {}, x86_64, ['getAllItemsFunction', 'getByIdFunction']), Current: BuildDefinition(nodejs20.x, C:\projects\samy2\fs-app\backend, Zip, , fa83f070-38d7-4538-a649-ae309cf4ca2c, {}, {}, x86_64, []), Function: Function(function_id='putItemFunction', name='putItemFunction', functionname='putItemFunction', runtime='nodejs20.x', memory=128, timeout=100, handler='src/handlers/put-item.putItemHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='C:\projects\samy2\fs-app\backend', environment={'Variables': {'SAMPLE_TABLE': 'SampleTable', 'ENDPOINT_OVERRIDE': ''}}, rolearn=None, layers=[], events={'Api': {'Type': 'Api', 'Properties': {'Path': '/', 'Method': 'POST', 'RestApiId': 'ApiGatewayApi'}}}, metadata={'SamResourceId': 'putItemFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None, function_build_info=<FunctionBuildInfo.BuildableZip: ('BuildableZip', 'Regular ZIP function which can be build with SAM CLI')>, stack_path='', runtime_management_config=None, logging_config={'LogFormat': 'JSON'})) 2024-04-12 14:15:10,227 | Async execution started 2024-04-12 14:15:10,227 | Invoking function functools.partial(<bound method ParallelBuildStrategy.build_single_function_definition of <samcli.lib.build.build_strategy.ParallelBuildStrategy object at 0x000001A29EB28F50>>, <samcli.lib.build.build_graph.FunctionBuildDefinition object at 0x000001A29ED74210>) 2024-04-12 14:15:10,227 | Running incremental build for runtime nodejs20.x for following resources (getAllItemsFunction, getByIdFunction, putItemFunction) 2024-04-12 14:15:10,243 | Waiting for async results 2024-04-12 14:15:10,243 | Cache is invalid, running build and copying resources for following functions (getAllItemsFunction, getByIdFunction, putItemFunction) 2024-04-12 14:15:10,243 | Building codeuri: C:\projects\samy2\fs-app\backend runtime: nodejs20.x metadata: {} architecture: x86_64 functions: getAllItemsFunction, getByIdFunction, putItemFunction 2024-04-12 14:15:10,243 | Building to following folder C:\projects\samy2\fs-app.aws-sam\build\getAllItemsFunction 2024-04-12 14:15:10,298 | Checking free port on 127.0.0.1:5353

Fetching public.ecr.aws/sam/build-nodejs20.x:latest-x86_64 Docker container image...... 2024-04-12 14:15:14,318 | Mounting C:\projects\samy2\fs-app\backend as /tmp/samcli/source:ro,delegated, inside runtime container Using the request object from command line argument Loading workflow module 'aws_lambda_builders.workflows' Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)' Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)' Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)' Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)' Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)' Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)' Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)' Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)' Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)' Registering workflow 'RustCargoLambdaBuilder' with capability 'Capability(language='rust', dependency_manager='cargo', application_framework=None)' Found workflow 'NodejsNpmBuilder' to support capabilities 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)' Running workflow 'NodejsNpmBuilder' Running NodejsNpmBuilder:NpmPack NODEJS packaging file:/tmp/samcli/source to /tmp/samcli/scratch executing NPM: ['npm', 'pack', '-q', 'file:/tmp/samcli/source'] NODEJS packed to delete-test-01-0.0.1.tgz NODEJS extracting to /tmp/samcli/scratch/unpacked NodejsNpmBuilder:NpmPack succeeded Running NodejsNpmBuilder:CopyNpmrcAndLockfile NodejsNpmBuilder:CopyNpmrcAndLockfile succeeded Running NodejsNpmBuilder:CopySource Creating target folders at /tmp/samcli/artifacts Copying directory metadata from source (/tmp/samcli/scratch/unpacked/package) to destination (/tmp/samcli/artifacts) Creating target folders at /tmp/samcli/artifacts/src Copying directory metadata from source (/tmp/samcli/scratch/unpacked/package/src) to destination (/tmp/samcli/artifacts/src) Creating target folders at /tmp/samcli/artifacts/src/handlers Copying directory metadata from source (/tmp/samcli/scratch/unpacked/package/src/handlers) to destination (/tmp/samcli/artifacts/src/handlers) Copying source file (/tmp/samcli/scratch/unpacked/package/src/handlers/get-by-id.mjs) to destination (/tmp/samcli/artifacts/src/handlers/get-by-id.mjs) Copying source file (/tmp/samcli/scratch/unpacked/package/src/handlers/put-item.mjs) to destination (/tmp/samcli/artifacts/src/handlers/put-item.mjs) Copying source file (/tmp/samcli/scratch/unpacked/package/src/handlers/get-all-items.mjs) to destination (/tmp/samcli/artifacts/src/handlers/get-all-items.mjs) Creating target folders at /tmp/samcli/artifacts/tests Copying directory metadata from source (/tmp/samcli/scratch/unpacked/package/tests) to destination (/tmp/samcli/artifacts/tests) Creating target folders at /tmp/samcli/artifacts/tests/unit Copying directory metadata from source (/tmp/samcli/scratch/unpacked/package/tests/unit) to destination (/tmp/samcli/artifacts/tests/unit) Creating target folders at /tmp/samcli/artifacts/tests/unit/handlers Copying directory metadata from source (/tmp/samcli/scratch/unpacked/package/tests/unit/handlers) to destination (/tmp/samcli/artifacts/tests/unit/handlers) Copying source file (/tmp/samcli/scratch/unpacked/package/tests/unit/handlers/put-item.test.mjs) to destination (/tmp/samcli/artifacts/tests/unit/handlers/put-item.test.mjs) Copying source file (/tmp/samcli/scratch/unpacked/package/tests/unit/handlers/get-all-items.test.mjs) to destination (/tmp/samcli/artifacts/tests/unit/handlers/get-all-items.test.mjs) Copying source file (/tmp/samcli/scratch/unpacked/package/tests/unit/handlers/get-by-id.test.mjs) to destination (/tmp/samcli/artifacts/tests/unit/handlers/get-by-id.test.mjs) Copying source file (/tmp/samcli/scratch/unpacked/package/package.json) to destination (/tmp/samcli/artifacts/package.json) NodejsNpmBuilder:CopySource succeeded Running NodejsNpmBuilder:NpmInstall NODEJS installing in: /tmp/samcli/artifacts executing NPM: ['npm', 'install', '-q', '--no-audit', '--no-save', '--unsafe-perm', '--production'] NodejsNpmBuilder:NpmInstall succeeded Running NodejsNpmBuilder:CleanUpNpmrc NodejsNpmBuilder:CleanUpNpmrc succeeded Running NodejsNpmBuilder:LockfileCleanUp .package-lock cleanup in: /tmp/samcli/artifacts NodejsNpmBuilder:LockfileCleanUp succeeded 2024-04-12 14:15:48,753 | Build inside container returned response {"jsonrpc": "2.0", "id": 1, "result": {"artifacts_dir": "/tmp/samcli/artifacts"}} 2024-04-12 14:15:48,758 | Build inside container was successful. Copying artifacts from container to host 2024-04-12 14:15:49,146 | Copying from container: /tmp/samcli/artifacts/. -> C:\projects\samy2\fs-app.aws-sam\build\getAllItemsFunction 2024-04-12 14:15:52,788 | Build inside container succeeded 2024-04-12 14:15:52,790 | Copying artifacts from C:\projects\samy2\fs-app.aws-sam\build\getAllItemsFunction to C:\projects\samy2\fs-app.aws-sam\build\getByIdFunction 2024-04-12 14:15:52,797 | Exception raised during the execution 2024-04-12 14:15:52,802 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics 2024-04-12 14:15:53,035 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics 2024-04-12 14:15:53,035 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '6f2c534f-cda7-47c3-a852-29bdfda277b2', 'installationId': 'e72464a8-b6ba-48e9-8660-f44265a00b6d', 'sessionId': '35f73912-f72f-461e-96ac-0d67cb48783e', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.8', 'samcliVersion': '1.115.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '1e1b5d38e48f3817647ec82e631ad6e0a32e89ee0568744147382e14326fb507', 'initialCommit': None}, 'duration': 43489, 'exitReason': 'OSError', 'exitCode': 255}}]} 2024-04-12 14:15:53,035 | Unable to find Click Context for getting session_id. 2024-04-12 14:15:53,053 | Sending Telemetry: {'metrics': [{'events': {'requestId': 'fd21520f-7d8f-49e2-b28b-e9da3c148230', 'installationId': 'e72464a8-b6ba-48e9-8660-f44265a00b6d', 'sessionId': '35f73912-f72f-461e-96ac-0d67cb48783e', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.8', 'samcliVersion': '1.115.0', 'commandName': 'sam build', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '5a3ab46ff1e34f0da787722bbb7908b8', 'time_stamp': '2024-04-12 08:45:09.255', 'exception_name': None}, {'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '53d47255286e4e22abb53a4bc2fd6e05', 'time_stamp': '2024-04-12 08:45:09.304', 'exception_name': None}, {'event_name': 'BuildWorkflowUsed', 'event_value': 'nodejs-npm', 'thread_id': 'be2ca9e129904aca97a2003c784abc36', 'time_stamp': '2024-04-12 08:45:10.180', 'exception_name': None}, {'event_name': 'BuildWorkflowUsed', 'event_value': 'nodejs-npm', 'thread_id': '2ae861410e00430d84fd60f892c9c845', 'time_stamp': '2024-04-12 08:45:10.180', 'exception_name': None}, {'event_name': 'BuildWorkflowUsed', 'event_value': 'nodejs-npm', 'thread_id': '85b81736bfeb4eccbaebb0c7235ddb82', 'time_stamp': '2024-04-12 08:45:10.180', 'exception_name': None}, {'event_name': 'BuildFunctionRuntime', 'event_value': 'nodejs20.x', 'thread_id': 'e5f6d519989d4f4db5e5226ab6de0aeb', 'time_stamp': '2024-04-12 08:45:10.180', 'exception_name': None}, {'event_name': 'BuildFunctionRuntime', 'event_value': 'nodejs20.x', 'thread_id': '67d26e2b5b024db1af11d0f1977d06ed', 'time_stamp': '2024-04-12 08:45:10.180', 'exception_name': None}, {'event_name': 'BuildFunctionRuntime', 'event_value': 'nodejs20.x', 'thread_id': '85c0068551f648acb70e2a4d10ca4130', 'time_stamp': '2024-04-12 08:45:10.180', 'exception_name': None}, {'event_name': 'BuildWorkflowUsed', 'event_value': 'nodejs-npm', 'thread_id': '877386e72de14f56b26f72ef1fc08fb9', 'time_stamp': '2024-04-12 08:45:10.259', 'exception_name': None}]}}}]} 2024-04-12 14:15:54,780 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1) 2024-04-12 14:15:54,795 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

Error: [Errno 22] Invalid argument: 'C:\projects\samy2\fs-app\.aws-sam\build\getAllItemsFunction\node_modules\.bin\fxparser' Traceback: File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\cli\cli_config_file.py", line 347, in wrapper return func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\decorators.py", line 92, in new_func return ctx.invoke(f, obj, *args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\telemetry\metric.py", line 185, in wrapped raise exception # pylint: disable=raising-bad-type ^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\telemetry\metric.py", line 150, in wrapped return_value = func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\version_checker.py", line 43, in wrapped actual_result = func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\cli\main.py", line 95, in wrapper return func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\commands\build\command.py", line 175, in cli do_cli( File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\commands\build\command.py", line 264, in do_cli ctx.run() File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\commands\build\build_context.py", line 284, in run self._build_result = builder.build() ^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\app_builder.py", line 225, in build return ApplicationBuildResult(build_graph, build_strategy.build()) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 413, in build return super().build() ^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 83, in build result.update(self._build_functions(self._build_graph)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 419, in _build_functions return self._run_builds_async( ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 435, in _run_builds_async async_results = async_context.run_async() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\async_utils.py", line 137, in run_async return run_given_tasks_async(self._async_tasks, event_loop) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\async_utils.py", line 96, in run_given_tasks_async return event_loop.run_until_complete(_run_given_tasks_async(tasks, event_loop, executor)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "asyncio\base_events.py", line 654, in run_until_complete File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\async_utils.py", line 62, in _run_given_tasks_async raise result File "concurrent\futures\thread.py", line 58, in run File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 446, in build_single_function_definition return self._delegate_build_strategy.build_single_function_definition(build_definition) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 592, in build_single_function_definition return self._cached_build_strategy.build_single_function_definition(build_definition) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 300, in build_single_function_definition build_result = self._delegate_build_strategy.build_single_function_definition(build_definition) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\build\build_strategy.py", line 197, in build_single_function_definition osutils.copytree(single_build_dir, artifacts_dir) File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\osutils.py", line 180, in copytree copytree(new_source, new_destination, ignore=ignore) File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\osutils.py", line 180, in copytree copytree(new_source, new_destination, ignore=ignore) File "C:\software\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\osutils.py", line 182, in copytree shutil.copy2(new_source, new_destination) File "shutil.py", line 448, in copy2 File "shutil.py", line 256, in copyfile

An unexpected error was encountered while executing "sam build". Search for an existing issue: https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20build%20-%20OSError Or create a bug report: https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20OSError

Expected result:

'sam build' command should execute successfully.

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

  1. OS: Windows 11
  2. sam --version: SAM CLI, version 1.115.0
  3. AWS region:
# Paste the output of `sam --info` here

sam --info { "version": "1.115.0", "system": { "python": "3.11.8", "os": "Windows-10-10.0.22631-SP0" }, "additional_dependencies": { "docker_engine": "24.0.5", "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" ] }

hnnasit commented 6 months ago

Hi @j0y0nt, thanks for reporting the issue and providing details. I am able to reproduce the error on a Windows machine for the full stack init template for nodejs20 runtime. Marking this as a bug.

github-actions[bot] commented 2 months ago

Patch is released in v1.122.0. Closing