Open betimer opened 1 year ago
Hi @betimer thanks for reaching out! Trying to understand the cause here, can I confirm with you that if you do not operate step 3 to rename, this issue does not occur?
Hi @qingchm
I tried again without renaming the folder.
And I can see that just after npm install @prisma/client
It begins to have this issue. Is that sam having issue with some packages?
@betimer Thanks for the response, seems like this is an issue that occurred during the build process when we download dependencies, would you mind running the command with --debug flag on and paste in more detailed logs here for me to investigate? That would be greatly appreciated
@qingchm
PS C:\xsrc\test\helper-funcs\lw-data-puller> sam build --debug
2023-01-26 10:03:15,144 | Config file location: C:\xsrc\test\helper-funcs\lw-data-puller\samconfig.toml
2023-01-26 10:03:15,146 | Config file 'C:\xsrc\test\helper-funcs\lw-data-puller\samconfig.toml' does not exist
2023-01-26 10:03:15,151 | Using SAM Template at C:\xsrc\test\helper-funcs\lw-data-puller\template.yaml
2023-01-26 10:03:15,398 | Using config file: samconfig.toml, config environment: default
2023-01-26 10:03:15,398 | Expand command line arguments to:
2023-01-26 10:03:15,398 | --template_file=C:\xsrc\test\helper-funcs\lw-data-puller\template.yaml --build_dir=.aws-sam\build --cache_dir=.aws-sam\cache
2023-01-26 10:03:16,616 | 'build' command is called
2023-01-26 10:03:16,620 | No Parameters detected in the template
2023-01-26 10:03:16,643 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2023-01-26 10:03:16,643 | There is no customer defined id or cdk path defined for resource ApplicationResourceGroup, so we will use the resource logical id as the resource id
2023-01-26 10:03:16,643 | There is no customer defined id or cdk path defined for resource ApplicationInsightsMonitoring, so we will use the resource logical id as the resource id
2023-01-26 10:03:16,643 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2023-01-26 10:03:16,644 | 0 stacks found in the template
2023-01-26 10:03:16,644 | No Parameters detected in the template
2023-01-26 10:03:16,655 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2023-01-26 10:03:16,656 | There is no customer defined id or cdk path defined for resource ApplicationResourceGroup, so we will use the resource logical id as the resource id
2023-01-26 10:03:16,656 | There is no customer defined id or cdk path defined for resource ApplicationInsightsMonitoring, so we will use the resource logical id as the resource id
2023-01-26 10:03:16,657 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2023-01-26 10:03:16,658 | 4 resources found in the stack
2023-01-26 10:03:16,658 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello-world/'
2023-01-26 10:03:16,659 | --base-dir is not presented, adjusting uri hello-world/ relative to C:\xsrc\test\helper-funcs\lw-data-puller\template.yaml
2023-01-26 10:03:16,672 | 4 resources found in the stack
2023-01-26 10:03:16,673 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello-world/'
2023-01-26 10:03:16,673 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello-world/'
2023-01-26 10:03:16,674 | --base-dir is not presented, adjusting uri hello-world/ relative to C:\xsrc\test\helper-funcs\lw-data-puller\template.yaml
2023-01-26 10:03:16,675 | Instantiating build definitions
2023-01-26 10:03:16,694 | Same function build definition found, adding function (Previous: BuildDefinition(nodejs18.x, C:\xsrc\test\helper-funcs\lw-data-puller\hello-world, Zip, , 87d9d1f5-8d25-44aa-b275-f11612b2b0e2, {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'Sourcemap': True, 'EntryPoints': ['app.ts']}}, {}, x86_64, []), Current: BuildDefinition(nodejs18.x, C:\xsrc\test\helper-funcs\lw-data-puller\hello-world, Zip, , 22c405d9-bec9-4a98-b241-05682c24d868, {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'Sourcemap': True, 'EntryPoints': ['app.ts']}}, {}, x86_64, []), Function: Function(function_id='HelloWorldFunction', name='HelloWorldFunction', functionname='HelloWorldFunction', runtime='nodejs18.x', memory=None, timeout=3, handler='app.lambdaHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='C:\\xsrc\\test\\helper-funcs\\lw-data-puller\\hello-world', environment=None, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'Api', 'Properties': {'Path': '/hello', 'Method': 'get', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'Sourcemap': True, 'EntryPoints': ['app.ts']}, 'SamResourceId': 'HelloWorldFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None, stack_path='', runtime_management_config=None))
2023-01-26 10:03:16,696 | Building codeuri: C:\xsrc\test\helper-funcs\lw-data-puller\hello-world runtime: nodejs18.x metadata: {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'Sourcemap': True, 'EntryPoints': ['app.ts']}} architecture: x86_64 functions: HelloWorldFunction
2023-01-26 10:03:16,697 | Building to following folder C:\xsrc\test\helper-funcs\lw-data-puller\.aws-sam\build\HelloWorldFunction
2023-01-26 10:03:16,699 | Loading workflow module 'aws_lambda_builders.workflows'
2023-01-26 10:03:16,718 | Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2023-01-26 10:03:16,730 | Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2023-01-26 10:03:16,736 | Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2023-01-26 10:03:16,749 | Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2023-01-26 10:03:16,767 | Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2023-01-26 10:03:16,783 | Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2023-01-26 10:03:16,797 | Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2023-01-26 10:03:16,812 | Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
2023-01-26 10:03:16,824 | Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'
2023-01-26 10:03:16,827 | Found workflow 'NodejsNpmEsbuildBuilder' to support capabilities 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'
2023-01-26 10:03:16,828 | executing NPM: ['npm.cmd', 'root']
2023-01-26 10:03:17,709 | Lambda Builders found the following esbuild properties:
{"minify": true, "target": "es2020", "sourcemap": true, "entry_points": ["app.ts"]}
2023-01-26 10:03:17,715 | Running workflow 'NodejsNpmEsbuildBuilder'
2023-01-26 10:03:17,715 | Running NodejsNpmEsbuildBuilder:CopySource
2023-01-26 10:03:17,716 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\.env) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\.env)
2023-01-26 10:03:17,718 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\.eslintignore) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\.eslintignore)
2023-01-26 10:03:17,719 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\.eslintrc.js) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\.eslintrc.js)
2023-01-26 10:03:17,721 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\.gitignore) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\.gitignore)
2023-01-26 10:03:17,723 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\.npmignore) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\.npmignore)
2023-01-26 10:03:17,724 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\.prettierrc.js) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\.prettierrc.js)
2023-01-26 10:03:17,725 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\app.ts) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\app.ts)
2023-01-26 10:03:17,727 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\jest.config.ts) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\jest.config.ts)
2023-01-26 10:03:17,732 | File (node_modules) is in ignored set, skipping it
2023-01-26 10:03:17,732 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\package-lock.json) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\package-lock.json)
2023-01-26 10:03:17,734 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\package.json) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\package.json)
2023-01-26 10:03:17,735 | Creating target folders at C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\prisma
2023-01-26 10:03:17,735 | Copying directory metadata from source (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\prisma) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\prisma)
2023-01-26 10:03:17,736 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\prisma\schema.prisma) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\prisma\schema.prisma)
2023-01-26 10:03:17,738 | Creating target folders at C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\tests
2023-01-26 10:03:17,738 | Copying directory metadata from source (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\tests) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\tests)
2023-01-26 10:03:17,739 | Creating target folders at C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\tests\unit
2023-01-26 10:03:17,739 | Copying directory metadata from source (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\tests\unit) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\tests\unit)
2023-01-26 10:03:17,740 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\tests\unit\test-handler.test.ts) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\tests\unit\test-handler.test.ts)
2023-01-26 10:03:17,741 | Copying source file (C:\xsrc\test\helper-funcs\lw-data-puller\hello-world\tsconfig.json) to destination (C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw\tsconfig.json)
2023-01-26 10:03:17,742 | NodejsNpmEsbuildBuilder:CopySource succeeded
2023-01-26 10:03:17,742 | Running NodejsNpmEsbuildBuilder:NpmInstall
2023-01-26 10:03:17,743 | NODEJS installing in: C:\Users\betim\AppData\Local\Temp\tmp0dxp9sgw
2023-01-26 10:03:17,743 | executing NPM: ['npm.cmd', 'install', '-q', '--no-audit', '--no-save', '--unsafe-perm', '--production']
2023-01-26 10:03:27,195 | NodejsNpmEsbuildBuilder:NpmInstall succeeded
2023-01-26 10:03:27,195 | Running NodejsNpmEsbuildBuilder:EsbuildBundle
2023-01-26 10:03:27,195 | NODEJS building ['C:\\Users\\betim\\AppData\\Local\\Temp\\tmp0dxp9sgw\\app.ts'] using esbuild to C:\xsrc\test\helper-funcs\lw-data-puller\.aws-sam\build\HelloWorldFunction
2023-01-26 10:03:27,195 | Using the following default args: ['--bundle', '--platform=node', '--outdir=C:\\xsrc\\test\\helper-funcs\\lw-data-puller\\.aws-sam\\build\\HelloWorldFunction', '--format=cjs']
2023-01-26 10:03:27,196 | Found the following args in the config: ['--minify', '--sourcemap', '--target=es2020']
2023-01-26 10:03:27,196 | checking for esbuild in: ['C:\\Users\\betim\\node_modules\\.bin']
2023-01-26 10:03:27,199 | potential esbuild binaries: ['C:\\Users\\betim\\AppData\\Roaming\\npm\\esbuild.CMD']
2023-01-26 10:03:27,200 | executing Esbuild: ['C:\\Users\\betim\\AppData\\Roaming\\npm\\esbuild.CMD', 'app.ts', '--bundle', '--platform=node', '--outdir=C:\\xsrc\\test\\helper-funcs\\lw-data-puller\\.aws-sam\\build\\HelloWorldFunction', '--format=cjs', '--minify', '--sourcemap', '--target=es2020']
2023-01-26 10:03:27,349 | NodejsNpmEsbuildBuilder:EsbuildBundle succeeded
2023-01-26 10:03:27,410 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-01-26 10:03:27,541 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-01-26 10:03:27,541 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '02267ee3-dd62-41cd-8c85-cf89d79190e5', 'installationId': 'cd053703-3a7b-4747-810c-de2bd43bd6bb', 'sessionId': '0e482360-8ad5-4778-9fc9-5591600571d0', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.71.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': 'f673268b4bb71792b05f3651d3a8ffabdfe6edb887c18ce348111085c33ecb72', 'projectName': '561615620ad6611c3163c312fb68c0a47e0b497750ff76f98bce9d7b98a6b2d0', 'initialCommit': '574dd9a3b3632e5a39b8cb7d4535c430c570677b592322fb4920f94e113191ba'}, 'duration': 12012, 'exitReason': 'PermissionError', 'exitCode': 255}}]}
2023-01-26 10:03:27,541 | Unable to find Click Context for getting session_id.
2023-01-26 10:03:27,543 | Sending Telemetry: {'metrics': [{'events': {'requestId': 'deb4bba8-70e4-4f47-a5ed-f741f95560a2', 'installationId': 'cd053703-3a7b-4747-810c-de2bd43bd6bb', 'sessionId': '0e482360-8ad5-4778-9fc9-5591600571d0', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.71.0', 'metricSpecificAttributes': {'events': [{'event_name': 'BuildWorkflowUsed', 'event_value': 'nodejs-npm-esbuild', 'thread_id': 17724, 'time_stamp': '2023-01-25 23:03:16.698'}]}}}]}
2023-01-26 10:03:28,352 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2023-01-26 10:03:28,368 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\betim\\AppData\\Local\\Temp\\tmp0dxp9sgw'
Traceback:
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1657, 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 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 183, 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 150, 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
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\build_context.py", line 261, in run
build_result = builder.build()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 214, 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 698, in _build_function
return self._build_function_in_process(
File "contextlib.py", line 120, in __exit__
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\osutils.py", line 55, in mkdir_temp
shutil.rmtree(temp_dir) File "shutil.py", line 740, in rmtree
File "shutil.py", line 622, in _rmtree_unsafe
File "shutil.py", line 620, in _rmtree_unsafe
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-%20PermissionError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20PermissionError
PS C:\xsrc\test\helper-funcs\lw-data-puller>
I get the same error as OP, but only 10% of the time it will happen.
When it does happen, if I re-run the same sam build
and without any code being changed it works.
sam build
sam build
sam deploy
I'm wondering if there's a really brief time a file is read by an editor or git or something, where a single retry or wait would fix.
I will try and see if I get capture one with --debug
At first I wondered if somehow aws-sam-cli has an issue if the cached dir .aws-sam
is read by vs code or github desktop or a terminal, etc.
But that didn't seem to make sense, because
I opened the directory ...\demo-runtime-layer-function\.aws-sam
directly as a new Vs Code instance. Hoping it would cause it to lock up while it's open. but sam build
works.
I can collect other diagnostics if I know what to do. I wasn't sure if the true cause is actually aws-sam-cli
or if the message was a herring.
--debug
Here's the short version
CustomMakeBuilder:MakeBuild succeeded
2023-07-19 11:27:03,526 | Failed to get the logs from the container
Traceback (most recent call last):
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\container.py", line 433, in _write_container_output
Found workflow 'CustomMakeBuilder' to support capabilities 'Capability(language='provided',
dependency_manager=None, application_framework=None)'
Running workflow 'CustomMakeBuilder'
Running CustomMakeBuilder:CopySource
Copying source file (/tmp/samcli/source/.gitignore) to destination (/tmp/samcli/scratch/.gitignore)
...
Copying source file (/tmp/samcli/source/ImportExcel/7.8.4/SUMMARY.md) to destination (/tmp/samcli/scratch/ImportExcel/7.8.4/SUMMARY.md)
Copying source file (/tmp/samcli/source/Makefile) to destination (/tmp/samcli/scratch/Makefile)
CustomMakeBuilder:CopySource succeeded
Running CustomMakeBuilder:MakeBuild
Current Artifacts Directory : /tmp/samcli/artifacts
executing Make: ['make', '--makefile', '/tmp/samcli/source/Makefile', 'build-AbcDemoPowerShellFunction']
cp -R . /tmp/samcli/artifacts
rm /tmp/samcli/artifacts/Makefile
CustomMakeBuilder:MakeBuild succeeded
2023-07-19 11:27:03,526 | Failed to get the logs from the container
Traceback (most recent call last):
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\container.py", line 433, 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)
```log
VERBOSE: Sam args: => build --use-container --parallel --cached --skip-pull-image --debug
2023-07-19 11:26:48,254 | Config file location: G:\user\demo-runtime-layer-function\samconfig.toml
2023-07-19 11:26:48,254 | Loading configuration values from [default.['build'].parameters] (env.command_name.section) in config file at 'G:\user\demo-runtime-layer-function\samconfig.toml'...
2023-07-19 11:26:48,258 | Configuration values successfully loaded.
2023-07-19 11:26:48,258 | Configuration values are: {}
2023-07-19 11:26:48,272 | Using SAM Template at G:\user\demo-runtime-layer-function\template.yml
2023-07-19 11:26:48,299 | Using config file: samconfig.toml, config environment: default
2023-07-19 11:26:48,300 | Expand command line arguments to:
2023-07-19 11:26:48,300 | --template_file=G:\user\demo-runtime-layer-function\template.yml --use_container --parallel --cached --skip_pull_image --mount_with=READ --build_dir=.aws-sam\build --cache_dir=.aws-sam\cache
2023-07-19 11:26:49,354 | 'build' command is called
2023-07-19 11:26:49,355 | Starting Build use cache
2023-07-19 11:26:49,355 | Starting Build inside a container
2023-07-19 11:26:49,374 | No Parameters detected in the template
2023-07-19 11:26:49,408 | There is no customer defined id or cdk path defined for resource AbcDemoPowerShellFunction, so we will use the resource logical id as the resource id
...
2023-07-19 11:26:49,410 | 0 stacks found in the template
2023-07-19 11:26:49,411 | No Parameters detected in the template
2023-07-19 11:26:49,428 | There is no customer defined id or cdk path defined for resource AbcDemoPowerShellFunction, so we will use the resource logical id as the resource id
...
2023-07-19 11:26:49,431 | 5 resources found in the stack
2023-07-19 11:26:49,431 | --base-dir is not presented, adjusting uri ../../awsAbc-powershell-runtime/source relative to G:\user\demo-runtime-layer-function\template.yml
2023-07-19 11:26:49,432 | --base-dir is not presented, adjusting uri H:/Abclayers/aws_email relative to G:\user\demo-runtime-layer-function\template.yml
2023-07-19 11:26:49,432 | Found Serverless function with name='AbcDemoPowerShellFunction' and CodeUri='function/'
2023-07-19 11:26:49,432 | --base-dir is not presented, adjusting uri function/ relative to G:\user\demo-runtime-layer-function\template.yml
2023-07-19 11:26:49,433 | --base-dir is not presented, adjusting uri ../../awsAbc-powershell-runtime/source relative to G:\user\demo-runtime-layer-function\template.yml
2023-07-19 11:26:49,434 | --base-dir is not presented, adjusting uri H:/Abclayers/aws_email relative to G:\user\demo-runtime-layer-function\template.yml
2023-07-19 11:26:49,450 | 5 resources found in the stack
2023-07-19 11:26:49,451 | Found Serverless function with name='AbcDemoPowerShellFunction' and CodeUri='function/'
2023-07-19 11:26:49,453 | Instantiating build definitions
2023-07-19 11:26:49,471 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(provided.al2, G:\user\demo-runtime-layer-function\function, Zip, , d2d3388d-9524-43d7-b853-2d9691dacc97, {'BuildMethod': 'makefile'}, {}, x86_64, []), Function: Function(function_id='AbcDemoPowerShellFunction', name='AbcDemoPowerShellFunction', functionname='AbcDemoPowerShellFunction', runtime='provided.al2', memory=1024, timeout=320, handler='examplehandler.ps1::handler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='G:\\temp\\2023-06-06-temp-Abc\\2023.03.17-Abc\\core\\src\\pass1\\lab-lambda-runtime\\examples\\demo-runtime-layer-function\\function', environment=None, rolearn='arn:aws:iam::954746088739:role/jumpcloud-lambda-executor', layers=[
@betimer Does yours error 100% of the time? Mine will fail sometimes, but never 100% of the time. Maybe that could be a useful clue.
When mine fails, I just re-run the same sam build
-- then it works.
> sam build ....
# error
> sam build ...
# good
> sam deploy
# good
@ninmonkey
For me, it is 100%. But there is a special package related prisma. It happens when adding prisma. I am curious why sam build will fail if adding some other package. So I think this should still be sam build
issue
A work around I created a layer for prisma.
@betimer Yes, I think it it is occurring in the sam cli. We are using different languages and get the same cli errors.
Something I noticed across our logs:
shutil.py
calling _rmtree_unsafe
100ms
?2023-01-26 10:03:27,200 | executing Esbuild: ['C:\\Users\\betim\\AppData\\Roaming\\npm\\esbuild.CMD', 'app.ts', '--bundle', '--platform=node', '--outdir=C:\\xsrc\\test\\helper-funcs\\lw-data-puller\\.aws-sam\\build\\HelloWorldFunction', '--format=cjs', '--minify', '--sourcemap', '--target=es2020'] 2023-01-26 10:03:27,349 | NodejsNpmEsbuildBuilder:EsbuildBundle succeeded 2023-01-26 10:03:28,352 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1) 2023-01-26 10:03:28,368 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1) ... File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 698, in _build_function return self._build_function_in_process( File "contextlib.py", line 120, in __exit__ File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\osutils.py", line 55, in mkdir_temp shutil.rmtree(temp_dir) File "shutil.py", line 740, in rmtree File "shutil.py", line 622, in _rmtree_unsafe File "shutil.py", line 620, in _rmtree_unsafe
Describe the bug
To reproduce
Expected behavior Success without any error (I have also tried to manually remove the temp file, but it turns out the error is consistent with each time it also generate again, so the root cause will be from
sam build
itself, and it generate the temp fileScreenshots Your Environment