SAM build - The directory is not empty error
See original GitHub issueDescription:
When performing sam build in quick succession from vscode terminal. It works the first once or twice but follows quickly with a "The directory is not empty error.
If I try to remove the .aws-sam folder manually via windows explorer I get an ‘folder denied message’ and get prompted to elevate to admin to remove. If I cancel and close vscode I can then remove the folder as expected. Looks like something is holding onto the folder.
Similar to #2012 but not using docker at this point
Steps to reproduce:
Perform sam build multiple times in quick succession.
Observed result:
Executing sam build --template-file C:\DevelopmentJS\mosaic-shell-modules\modules\poc-animals\api\template.cfn.yaml --debug
2020-12-14 09:56:37,089 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-14 09:56:37,105 | 'build' command is called
2020-12-14 09:56:37,122 | Collected default values for parameters: {'Environment': 'non-production'}
2020-12-14 09:56:37,206 | 12 resources found in the template
2020-12-14 09:56:37,206 | Found Serverless function with name='dogsList' and CodeUri='.'
2020-12-14 09:56:37,206 | Found Serverless function with name='dogsPost' and CodeUri='.'
2020-12-14 09:56:37,206 | Found Serverless function with name='dogsGet' and CodeUri='.'
2020-12-14 09:56:37,206 | Found Serverless function with name='dogsUpdate' and CodeUri='.'
2020-12-14 09:56:37,206 | Found Serverless function with name='dogsDelete' and CodeUri='.'
2020-12-14 09:56:37,206 | Found Serverless function with name='fishList' and CodeUri='.'
2020-12-14 09:56:37,206 | Found Serverless function with name='fishPost' and CodeUri='.'
2020-12-14 09:56:37,207 | Found Serverless function with name='fishGet' and CodeUri='.'
2020-12-14 09:56:37,207 | Found Serverless function with name='fishUpdate' and CodeUri='.'
2020-12-14 09:56:37,207 | Found Serverless function with name='fishDelete' and CodeUri='.'
2020-12-14 09:56:37,207 | Collected default values for parameters: {'Environment': 'non-production'}
2020-12-14 09:56:37,278 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 188, 'exitReason': 'OSError', 'exitCode': 255, 'requestId': '767d2253-9c0a-49d6-9be2-3d6c1d33a692', 'installationId': '3a4a8ddc-e448-40c5-bd7c-c813144a84db', 'sessionId': 'fa4326df-6463-4549-a69a-9dc21f508775', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.11.0'}}]}
2020-12-14 09:56:38,104 | 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\metrics.py", line 148, in wrapped
raise exception # pylint: disable=raising-bad-type
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metrics.py", line 114, in wrapped
return_value = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\command.py", line 156, in cli
do_cli(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\command.py", line 214, in do_cli
with BuildContext(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\build_context.py", line 73, in __enter__
self._build_dir = self._setup_build_dir(self._build_dir, self._clean)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\build_context.py", line 105, in _setup_build_dir
shutil.rmtree(build_dir)
File "shutil.py", line 737, in rmtree
File "shutil.py", line 610, in _rmtree_unsafe
File "shutil.py", line 610, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
File "shutil.py", line 617, in _rmtree_unsafe
OSError: [WinError 145] The directory is not empty: '.aws-sam\\build\\dogsDelete\\handlers'
Expected result:
For sam to remove the old .aws-sam folder and build as expected
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Windows 10
sam --version
: SAM CLI, version 1.11.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
sam build - AWS Serverless Application Model
The sam build command processes your AWS SAM template file, application code, and any applicable language-specific files and dependencies. The command also ...
Read more >How to solve "The directory is not empty" error when running ...
I ran into a scenario where some sub directories within mydir produced the same "not empty" error. So I had to cd into...
Read more >[SOLVED] Error The Directory is Not Empty Problem Issue
[SOLVED] Error The Directory is Not Empty Problem IssueWhen deleting a folder, if you receive Error 0x80070091 The directory is not empty ......
Read more >Working With Files and Directories – The Unix Shell
Using the shell to create a directory is no different than using a file explorer. If you open the current directory using your...
Read more >Errors in SAM or BAM files can be diagnosed with ... - GATK
You're trying to run a GATK or Picard tool that operates on a SAM or BAM file, and getting some cryptic error that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the feedback @cailinw and @sohah
Can you provide a simple project setup that we can test and try to re-produce this issue?
No updates on this issue for while. Does anybody still experiencing it in last VSCode with last SAM CLI?