aws-sam-cli: Sam Build Fails with pywintypes.error: (109, 'ReadFile', 'The pipe has been ended.')
Description:
When ever I do a sam build I get an error that says “pywintypes.error: (109, ‘ReadFile’, ‘The pipe has been ended.’)”. This even happens with a new “Hello World” project started with sam init.
Steps to reproduce:
Simplest way I reproduced it
sam init (use Hello World templates, python 3.9, zip) sam buld --use-container
Observed result:
output is from our project and not the hello world. Got the same results using hello world.
C:\Users\work\Documents\Sam>"C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd" build Function --template C:\Users\work\PycharmProjects\SmallBizPython\.aws-sam\temp-template.yaml --build-dir C:\Users\work\PycharmProjects\SmallBizPython\.aws-sam\build --use-container --debug
2022-09-06 10:27:53,336 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-09-06 10:27:53,336 | Using config file: samconfig.toml, config environment: default
2022-09-06 10:27:53,336 | Expand command line arguments to:
2022-09-06 10:27:53,336 | --template_file=C:\Users\work\PycharmProjects\SmallBizPython\.aws-sam\temp-template.yaml --build_dir=C:\Users\work\PycharmProjects\SmallBizPython\.aws-sam\build --use_container --resource_logical_id=Function --cache_dir=.aws-sam\cache
2022-09-06 10:27:56,067 | 'build' command is called
2022-09-06 10:27:56,067 | Starting Build inside a container
2022-09-06 10:27:56,067 | No Parameters detected in the template
2022-09-06 10:27:56,145 | There is no customer defined id or cdk path defined for resource Function, so we will use the resource logical id as the resource id
2022-09-06 10:27:56,145 | 0 stacks found in the template
2022-09-06 10:27:56,145 | No Parameters detected in the template
2022-09-06 10:27:56,176 | There is no customer defined id or cdk path defined for resource Function, so we will use the resource logical id as the resource id
2022-09-06 10:27:56,176 | 1 resources found in the stack
2022-09-06 10:27:56,176 | Found Serverless function with name='Function' and CodeUri='C:\Users\work\PycharmProjects\SmallBizPython\SmallBiz'
2022-09-06 10:27:56,176 | --base-dir is not presented, adjusting uri C:\Users\work\PycharmProjects\SmallBizPython\SmallBiz relative to C:\Users\work\PycharmProjects\SmallBizPython\.aws-sam\temp-template.yaml
2022-09-06 10:27:56,192 | 1 resources found in the stack
2022-09-06 10:27:56,192 | Found Serverless function with name='Function' and CodeUri='C:\Users\work\PycharmProjects\SmallBizPython\SmallBiz'
2022-09-06 10:27:56,192 | Instantiating build definitions
2022-09-06 10:27:56,192 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(python3.9, C:\Users\work\PycharmProjects\SmallBizPython\SmallBiz, Zip, , 2de79bf7-6d16-4efb-b204-a6a30a6915aa, {}, {}, x86_64, []), Function: Function(function_id='Function', name='Function', functionname='Function', runtime='python3.9', memory=128, timeout=300, handler='Activity.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='C:\\Users\\work\\PycharmProjects\\SmallBizPython\\SmallBiz', environment={'Variables': {'app_prefix': 'cae'}}, rolearn=None, layers=[], events=None, metadata={'SamResourceId': 'Function'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None, stack_path=''))
2022-09-06 10:27:56,192 | Building codeuri: C:\Users\work\PycharmProjects\SmallBizPython\SmallBiz runtime: python3.9 metadata: {} architecture: x86_64 functions: Function
2022-09-06 10:27:56,192 | Building to following folder C:\Users\work\PycharmProjects\SmallBizPython\.aws-sam\build\Function
Fetching public.ecr.aws/sam/build-python3.9:latest-x86_64 Docker container image......
2022-09-06 10:27:57,345 | Mounting C:\Users\work\PycharmProjects\SmallBizPython\SmallBiz 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 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', 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 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'
Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Running workflow 'PythonPipBuilder'
Running PythonPipBuilder:ResolveDependencies
calling pip download -r /tmp/samcli/source/requirements.txt --dest /tmp/samcli/scratch --exists-action i
Full dependency closure: {rsa==4.9(wheel), python-dateutil==2.8.2(wheel), ecdsa==0.18.0(wheel), pytz-deprecation-shim==0.1.0.post0(wheel), paramiko==2.11.0(wheel), pycparser==2.21(wheel), bcrypt==4.0.0(wheel), boto3==1.24.66(wheel), python-jose==3.3.0(wheel), pysftp==0.2.9(sdist), pytz==2022.2.1(wheel), certifi==2022.6.15(wheel), oauthlib==3.2.0(wheel), future==0.18.2(sdist), tzdata==2022.2(wheel), jmespath==1.0.1(wheel), requests-oauthlib==1.3.1(wheel), intuit-oauth==1.2.4(wheel), s3transfer==0.6.0(wheel), urllib3==1.26.12(wheel), cryptography==37.0.4(wheel), requests==2.28.1(wheel), cffi==1.15.1(wheel), enum-compat==0.0.3(wheel), pynacl==1.5.0(wheel), tzlocal==4.2(wheel), six==1.16.0(wheel), attrs==22.1.0(wheel), idna==3.3(wheel), pyasn1==0.4.8(wheel), charset-normalizer==2.1.1(wheel), botocore==1.27.66(wheel)}
initial compatible: {rsa==4.9(wheel), python-dateutil==2.8.2(wheel), ecdsa==0.18.0(wheel), pytz-deprecation-shim==0.1.0.post0(wheel), paramiko==2.11.0(wheel), pycparser==2.21(wheel), bcrypt==4.0.0(wheel), boto3==1.24.66(wheel), python-jose==3.3.0(wheel), certifi==2022.6.15(wheel), pytz==2022.2.1(wheel), oauthlib==3.2.0(wheel), tzdata==2022.2(wheel), jmespath==1.0.1(wheel), requests-oauthlib==1.3.1(wheel), intuit-oauth==1.2.4(wheel), s3transfer==0.6.0(wheel), urllib3==1.26.12(wheel), cryptography==37.0.4(wheel), requests==2.28.1(wheel), cffi==1.15.1(wheel), enum-compat==0.0.3(wheel), pynacl==1.5.0(wheel), tzlocal==4.2(wheel), six==1.16.0(wheel), attrs==22.1.0(wheel), idna==3.3(wheel), pyasn1==0.4.8(wheel), charset-normalizer==2.1.1(wheel), botocore==1.27.66(wheel)}
initial incompatible: {future==0.18.2(sdist), pysftp==0.2.9(sdist)}
Downloading missing wheels: {future==0.18.2(sdist), pysftp==0.2.9(sdist)}
calling pip download --only-binary=:all: --no-deps --platform manylinux2014_x86_64 --implementation cp --abi cp39 --dest /tmp/samcli/scratch future==0.18.2
calling pip download --only-binary=:all: --no-deps --platform manylinux2014_x86_64 --implementation cp --abi cp39 --dest /tmp/samcli/scratch pysftp==0.2.9
compatible wheels after second download pass: {rsa==4.9(wheel), python-dateutil==2.8.2(wheel), ecdsa==0.18.0(wheel), pytz-deprecation-shim==0.1.0.post0(wheel), paramiko==2.11.0(wheel), pycparser==2.21(wheel), bcrypt==4.0.0(wheel), boto3==1.24.66(wheel), python-jose==3.3.0(wheel), pytz==2022.2.1(wheel), certifi==2022.6.15(wheel), oauthlib==3.2.0(wheel), tzdata==2022.2(wheel), jmespath==1.0.1(wheel), requests-oauthlib==1.3.1(wheel), intuit-oauth==1.2.4(wheel), s3transfer==0.6.0(wheel), urllib3==1.26.12(wheel), cryptography==37.0.4(wheel), requests==2.28.1(wheel), cffi==1.15.1(wheel), enum-compat==0.0.3(wheel), pynacl==1.5.0(wheel), tzlocal==4.2(wheel), six==1.16.0(wheel), attrs==22.1.0(wheel), idna==3.3(wheel), pyasn1==0.4.8(wheel), charset-normalizer==2.1.1(wheel), botocore==1.27.66(wheel)}
Build missing wheels from sdists (C compiling True): {future==0.18.2(sdist), pysftp==0.2.9(sdist)}
calling pip wheel --no-deps --wheel-dir /tmp/samcli/scratch /tmp/samcli/scratch/future-0.18.2.tar.gz
calling pip wheel --no-deps --wheel-dir /tmp/samcli/scratch /tmp/samcli/scratch/pysftp-0.2.9.tar.gz
compatible after building wheels (no C compiling): {rsa==4.9(wheel), python-dateutil==2.8.2(wheel), ecdsa==0.18.0(wheel), pytz-deprecation-shim==0.1.0.post0(wheel), paramiko==2.11.0(wheel), pycparser==2.21(wheel), bcrypt==4.0.0(wheel), boto3==1.24.66(wheel), python-jose==3.3.0(wheel), pysftp==0.2.9(wheel), pytz==2022.2.1(wheel), certifi==2022.6.15(wheel), oauthlib==3.2.0(wheel), future==0.18.2(wheel), tzdata==2022.2(wheel), jmespath==1.0.1(wheel), requests-oauthlib==1.3.1(wheel), intuit-oauth==1.2.4(wheel), s3transfer==0.6.0(wheel), urllib3==1.26.12(wheel), cryptography==37.0.4(wheel), requests==2.28.1(wheel), cffi==1.15.1(wheel), enum-compat==0.0.3(wheel), pynacl==1.5.0(wheel), tzlocal==4.2(wheel), six==1.16.0(wheel), attrs==22.1.0(wheel), idna==3.3(wheel), pyasn1==0.4.8(wheel), charset-normalizer==2.1.1(wheel), botocore==1.27.66(wheel)}
Build missing wheels from sdists (C compiling False): set()
compatible after building wheels (C compiling): {rsa==4.9(wheel), python-dateutil==2.8.2(wheel), ecdsa==0.18.0(wheel), pytz-deprecation-shim==0.1.0.post0(wheel), paramiko==2.11.0(wheel), pycparser==2.21(wheel), bcrypt==4.0.0(wheel), boto3==1.24.66(wheel), python-jose==3.3.0(wheel), pysftp==0.2.9(wheel), pytz==2022.2.1(wheel), certifi==2022.6.15(wheel), oauthlib==3.2.0(wheel), future==0.18.2(wheel), tzdata==2022.2(wheel), jmespath==1.0.1(wheel), requests-oauthlib==1.3.1(wheel), intuit-oauth==1.2.4(wheel), s3transfer==0.6.0(wheel), urllib3==1.26.12(wheel), cryptography==37.0.4(wheel), requests==2.28.1(wheel), cffi==1.15.1(wheel), enum-compat==0.0.3(wheel), pynacl==1.5.0(wheel), tzlocal==4.2(wheel), six==1.16.0(wheel), attrs==22.1.0(wheel), idna==3.3(wheel), pyasn1==0.4.8(wheel), charset-normalizer==2.1.1(wheel), botocore==1.27.66(wheel)}
Final compatible: {rsa==4.9(wheel), python-dateutil==2.8.2(wheel), ecdsa==0.18.0(wheel), pytz-deprecation-shim==0.1.0.post0(wheel), paramiko==2.11.0(wheel), pycparser==2.21(wheel), bcrypt==4.0.0(wheel), boto3==1.24.66(wheel), python-jose==3.3.0(wheel), pysftp==0.2.9(wheel), pytz==2022.2.1(wheel), certifi==2022.6.15(wheel), oauthlib==3.2.0(wheel), future==0.18.2(wheel), tzdata==2022.2(wheel), jmespath==1.0.1(wheel), requests-oauthlib==1.3.1(wheel), intuit-oauth==1.2.4(wheel), s3transfer==0.6.0(wheel), urllib3==1.26.12(wheel), cryptography==37.0.4(wheel), requests==2.28.1(wheel), cffi==1.15.1(wheel), enum-compat==0.0.3(wheel), pynacl==1.5.0(wheel), tzlocal==4.2(wheel), six==1.16.0(wheel), attrs==22.1.0(wheel), idna==3.3(wheel), pyasn1==0.4.8(wheel), charset-normalizer==2.1.1(wheel), botocore==1.27.66(wheel)}
Final incompatible: set()
Final missing wheels: set()
PythonPipBuilder:ResolveDependencies succeeded
Running PythonPipBuilder:CopySource
Copying source file (/tmp/samcli/source/.DS_Store) to destination (/tmp/samcli/artifacts/.DS_Store)
Copying source file (/tmp/samcli/source/Account.py) to destination (/tmp/samcli/artifacts/Account.py)
Copying source file (/tmp/samcli/source/AccountMapping.py) to destination (/tmp/samcli/artifacts/AccountMapping.py)
Copying source file (/tmp/samcli/source/Activity.py) to destination (/tmp/samcli/artifacts/Activity.py)
Copying source file (/tmp/samcli/source/AdminUser.py) to destination (/tmp/samcli/artifacts/AdminUser.py)
Copying source file (/tmp/samcli/source/checkDataForBatch.py) to destination (/tmp/samcli/artifacts/checkDataForBatch.py)
Copying source file (/tmp/samcli/source/Custom.py) to destination (/tmp/samcli/artifacts/Custom.py)
Copying source file (/tmp/samcli/source/DecimalEncoder.py) to destination (/tmp/samcli/artifacts/DecimalEncoder.py)
Copying source file (/tmp/samcli/source/DeleteQBFile.py) to destination (/tmp/samcli/artifacts/DeleteQBFile.py)
Copying source file (/tmp/samcli/source/DeleteUtils.py) to destination (/tmp/samcli/artifacts/DeleteUtils.py)
Copying source file (/tmp/samcli/source/Errors.py) to destination (/tmp/samcli/artifacts/Errors.py)
Copying source file (/tmp/samcli/source/ExchangeToken.py) to destination (/tmp/samcli/artifacts/ExchangeToken.py)
Copying source file (/tmp/samcli/source/GetCheckRegisters.py) to destination (/tmp/samcli/artifacts/GetCheckRegisters.py)
Copying source file (/tmp/samcli/source/GetImportBatches.py) to destination (/tmp/samcli/artifacts/GetImportBatches.py)
Copying source file (/tmp/samcli/source/GetOAuthURL.py) to destination (/tmp/samcli/artifacts/GetOAuthURL.py)
Copying source file (/tmp/samcli/source/GetQBFiles.py) to destination (/tmp/samcli/artifacts/GetQBFiles.py)
Copying source file (/tmp/samcli/source/ImportBatch.py) to destination (/tmp/samcli/artifacts/ImportBatch.py)
Copying source file (/tmp/samcli/source/OAuthSettings.py) to destination (/tmp/samcli/artifacts/OAuthSettings.py)
Copying source file (/tmp/samcli/source/QuickbooksConnector.py) to destination (/tmp/samcli/artifacts/QuickbooksConnector.py)
Copying source file (/tmp/samcli/source/requirements.txt) to destination (/tmp/samcli/artifacts/requirements.txt)
Copying source file (/tmp/samcli/source/RetrieveTrans.py) to destination (/tmp/samcli/artifacts/RetrieveTrans.py)
Copying source file (/tmp/samcli/source/runNow.py) to destination (/tmp/samcli/artifacts/runNow.py)
Copying source file (/tmp/samcli/source/RunScheduler.py) to destination (/tmp/samcli/artifacts/RunScheduler.py)
Copying source file (/tmp/samcli/source/SageBusinesses.py) to destination (/tmp/samcli/artifacts/SageBusinesses.py)
Copying source file (/tmp/samcli/source/SageUtils.py) to destination (/tmp/samcli/artifacts/SageUtils.py)
Copying source file (/tmp/samcli/source/SessionData.py) to destination (/tmp/samcli/artifacts/SessionData.py)
Copying source file (/tmp/samcli/source/Settings.py) to destination (/tmp/samcli/artifacts/Settings.py)
Copying source file (/tmp/samcli/source/Utils.py) to destination (/tmp/samcli/artifacts/Utils.py)
Copying source file (/tmp/samcli/source/__init__.py) to destination (/tmp/samcli/artifacts/__init__.py)
PythonPipBuilder:CopySource succeeded
2022-09-06 10:28:35,445 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-09-06 10:28:35,445 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'b28c117b-b30f-4cb7-a4b5-845255ec23ae', 'installationId': 'ab966ed1-5790-48f5-90e5-a05303489f1f', 'sessionId': '8c966d70-5d92-4910-9cd9-6264646854ad', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.56.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '5a9c2935bb9fee16ad433a62af9a4535bd9c44e3708f6127bcbfa38f4e915b7b', 'initialCommit': None}, 'duration': 42108, 'exitReason': 'error', 'exitCode': 255, 'stackTrace': 'Traceback (most recent call last):\n File "\\..\\site-packages\\samcli\\lib\\telemetry\\metric.py", line 129, in wrapped\n return_value = func(*args, **kwargs)\n File "\\..\\site-packages\\samcli\\lib\\utils\\version_checker.py", line 41, in wrapped\n actual_result = func(*args, **kwargs)\n File "\\..\\site-packages\\samcli\\cli\\main.py", line 87, in wrapper\n return func(*args, **kwargs)\n File "\\..\\site-packages\\samcli\\commands\\build\\command.py", line 182, in cli\n do_cli(\n File "\\..\\site-packages\\samcli\\commands\\build\\command.py", line 262, in do_cli\n ctx.run()\n File "\\..\\site-packages\\samcli\\commands\\build\\build_context.py", line 252, in run\n build_result = builder.build()\n File "\\..\\site-packages\\samcli\\lib\\build\\app_builder.py", line 221, in build\n return ApplicationBuildResult(build_graph, build_strategy.build())\n File "\\..\\site-packages\\samcli\\lib\\build\\build_strategy.py", line 80, in build\n result.update(self._build_functions(self._build_graph))\n File "\\..\\site-packages\\samcli\\lib\\build\\build_strategy.py", line 90, in _build_functions\n function_build_results.update(self.build_single_function_definition(build_definition))\n File "\\..\\site-packages\\samcli\\lib\\build\\build_strategy.py", line 163, in build_single_function_definition\n result = self._build_function(\n File "\\..\\site-packages\\samcli\\lib\\build\\app_builder.py", line 645, in _build_function\n return self._build_function_on_container(\n File "\\..\\site-packages\\samcli\\lib\\build\\app_builder.py", line 831, in _build_function_on_container\n container.wait_for_logs(stdout=stdout_stream, stderr=stderr_stream)\n File "\\..\\site-packages\\samcli\\local\\docker\\container.py", line 335, in wait_for_logs\n self._write_container_output(logs_itr, stdout=stdout, stderr=stderr)\n File "\\..\\site-packages\\samcli\\local\\docker\\container.py", line 400, in _write_container_output\n for stdout_data, stderr_data in output_itr:\n File "\\..\\site-packages\\docker\\types\\daemon.py", line 32, in __next__\n return next(self._stream)\n File "\\..\\site-packages\\docker\\api\\client.py", line 406, in <genexpr>\n gen = (demux_adaptor(*frame) for frame in gen)\n File "\\..\\site-packages\\docker\\utils\\socket.py", line 94, in frames_iter_no_tty\n (stream, n) = next_frame_header(socket)\n File "\\..\\site-packages\\docker\\utils\\socket.py", line 66, in next_frame_header\n data = read_exactly(socket, 8)\n File "\\..\\site-packages\\docker\\utils\\socket.py", line 51, in read_exactly\n next_data = read(socket, n - len(data))\n File "\\..\\site-packages\\docker\\utils\\socket.py", line 35, in read\n return socket.recv(n)\n File "\\..\\site-packages\\docker\\transport\\npipesocket.py", line 23, in wrapped\n return f(self, *args, **kwargs)\n File "\\..\\site-packages\\docker\\transport\\npipesocket.py", line 117, in recv\n err, data = win32file.ReadFile(self._handle, bufsize)\npywintypes.error: (109, \'ReadFile\', \'The pipe has been ended.\')\n', 'exceptionMessage': "pywintypes.error: (109, 'ReadFile', 'The pipe has been ended.')\n"}}]}
2022-09-06 10:28:35,445 | Unable to find Click Context for getting session_id.
2022-09-06 10:28:35,445 | Sending Telemetry: {'metrics': [{'events': {'requestId': 'ab37d1ef-c979-4a23-9131-db67ec1afc1a', 'installationId': 'ab966ed1-5790-48f5-90e5-a05303489f1f', 'sessionId': '8c966d70-5d92-4910-9cd9-6264646854ad', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.56.0', 'metricSpecificAttributes': {'events': [{'event_name': 'BuildWorkflowUsed', 'event_value': 'python-pip', 'thread_id': 22508, 'time_stamp': '2022-09-06 14:27:56.192'}]}}}]}
2022-09-06 10:28:36,004 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2022-09-06 10:28:36,004 | 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 "runpy.py", line 194, in _run_module_as_main
File "runpy.py", line 87, 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\metric.py", line 181, in wrapped
raise exception # pylint: disable=raising-bad-type
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 129, in wrapped
return_value = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\version_checker.py", line 41, in wrapped
actual_result = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\cli\main.py", line 87, in wrapper
return func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\command.py", line 182, in cli
do_cli(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\command.py", line 262, in do_cli
ctx.run()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\build_context.py", line 252, in run
build_result = builder.build()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 221, in build
return ApplicationBuildResult(build_graph, build_strategy.build())
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\build_strategy.py", line 80, in build
result.update(self._build_functions(self._build_graph))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\build_strategy.py", line 90, in _build_functions
function_build_results.update(self.build_single_function_definition(build_definition))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\build_strategy.py", line 163, in build_single_function_definition
result = self._build_function(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 645, in _build_function
return self._build_function_on_container(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 831, in _build_function_on_container
container.wait_for_logs(stdout=stdout_stream, stderr=stderr_stream)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\container.py", line 335, in wait_for_logs
self._write_container_output(logs_itr, stdout=stdout, stderr=stderr)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\container.py", line 400, in _write_container_output
for stdout_data, stderr_data in output_itr:
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\types\daemon.py", line 32, in __next__
return next(self._stream)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\api\client.py", line 406, in <genexpr>
gen = (demux_adaptor(*frame) for frame in gen)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\utils\socket.py", line 94, in frames_iter_no_tty
(stream, n) = next_frame_header(socket)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\utils\socket.py", line 66, in next_frame_header
data = read_exactly(socket, 8)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\utils\socket.py", line 51, in read_exactly
next_data = read(socket, n - len(data))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\utils\socket.py", line 35, in read
return socket.recv(n)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\transport\npipesocket.py", line 23, in wrapped
return f(self, *args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\transport\npipesocket.py", line 117, in recv
err, data = win32file.ReadFile(self._handle, bufsize)
pywintypes.error: (109, 'ReadFile', 'The pipe has been ended.')
Expected result:
Build to complete successfully
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Edition Windows 11 Home Version 21H2 OS build 22000.856 Experience Windows Feature Experience Pack 1000.22000.856.0
AWS CLI Version: aws-cli/2.7.29 Python/3.9.11 Windows/10 exe/AMD64 prompt/off Docker: 4.12.0 SAM Version: SAM CLI, version 1.56.0 PyCharm: 2022.2.1
As a workaround, I downgraded docker desktop to 4.11.1 and the project builds successfully. At some point I will have to update docker that is Why I am creating this ticket.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 23 (6 by maintainers)
@chmuths If you need to use the CLI, uninstall your Docker Desktop v.4.12.0 and reinstall using the v4.11.1 installer (download link from Docker docs: Docker Desktop 4.11.1 for Windows. I have downgraded to 4.11.1 and can build without issues.
I did confirm that docker version 4.12.0 in windows is failing to run
sam build -u
andsam local
commands. We will be investigating the root cause of it.I had this issue on Win11. Disabling Hyper-V solved the issue. Sam CLI: 1.78.0 Docker: v4.17.1
This fix has now been released in version 1.58.0 on 09/29. Please re-open this issue if needed.
I got it working again using the nightly build of SAM:
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-windows.html#serverless-sam-cli-install-windows-nightly-build
We’ve raised the PR for the fix. Our assumption is, when you try to read the logs from the container which is done its work it started to raise an exception on Windows with v4.12.0.
This fix should be out with next SAM CLI release. In the meantime, if someone has a different exception trace, please share it here so that we can fix the issue there as well.