Error while deploying SAM application using WSL2
See original GitHub issueWhile deploying a SAM application I get an error regarding the locale setting, even though this setting is set everywhere correctly.
Starting SAM Application deployment...
Building SAM Application...
Packaging SAM Application to S3 Bucket: mattg2019test
Error with child process: Traceback (most recent call last):
File "/home/matt/.local/bin/sam", line 8, in <module>
sys.exit(cli())
File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 760, in main
_verify_python3_env()
File "/home/matt/.local/lib/python3.6/site-packages/click/_unicodefun.py", line 130, in _verify_python3_env
" mitigation steps.{}".format(extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/python3/ for mitigation steps.
This system supports the C.UTF-8 locale which is recommended. You might be able to resolve your issue by exporting the following environment variables:
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
An error occurred while deploying a SAM Application. Check the logs for more information by running the "View AWS Toolkit Logs" command from the Command Palette.
Manual deployment within my WSL2 shell works as expected. It appears my shell variables are not being picked up by the extension. In VS Code developer tools, process.env just shows Windows environment variables and not Linux ones so the required locale is not listed.
AWS Toolkit logs are not providing further clarity:
2020-09-21 16:31:30 [INFO]: Running command: /home/matt/.local/bin/sam --info
2020-09-21 16:32:09 [INFO]: Starting SAM Application deployment...
2020-09-21 16:32:09 [INFO]: Building SAM Application...
2020-09-21 16:32:09 [INFO]: Running command: /home/matt/.local/bin/sam build --build-dir /tmp/aws-toolkit-vscode/samDeployWNsLsc/build --template /path/to/template.yaml
2020-09-21 16:32:12 [INFO]: Packaging SAM Application to S3 Bucket: mattg2019test
2020-09-21 16:32:12 [INFO]: Running command: /home/matt/.local/bin/sam package --template-file /tmp/aws-toolkit-vscode/samDeployWNsLsc/build/template.yaml --s3-bucket xxx --output-template-file /tmp/aws-toolkit-vscode/samDeployWNsLsc/template.yaml --region ap-southeast-2
2020-09-21 16:32:13 [ERROR]: Unexpected exitcode (1), expecting (0)
2020-09-21 16:32:13 [ERROR]: Error: undefined
2020-09-21 16:32:13 [ERROR]: stderr: Traceback (most recent call last):
File "/home/matt/.local/bin/sam", line 8, in <module>
sys.exit(cli())
File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 760, in main
_verify_python3_env()
File "/home/matt/.local/lib/python3.6/site-packages/click/_unicodefun.py", line 130, in _verify_python3_env
" mitigation steps.{}".format(extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/python3/ for mitigation steps.
This system supports the C.UTF-8 locale which is recommended. You might be able to resolve your issue by exporting the following environment variables:
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
2020-09-21 16:32:13 [ERROR]: stdout:
2020-09-21 16:32:13 [ERROR]: Error: Error with child process: Traceback (most recent call last):
File "/home/matt/.local/bin/sam", line 8, in <module>
sys.exit(cli())
File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 760, in main
_verify_python3_env()
File "/home/matt/.local/lib/python3.6/site-packages/click/_unicodefun.py", line 130, in _verify_python3_env
" mitigation steps.{}".format(extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/python3/ for mitigation steps.
This system supports the C.UTF-8 locale which is recommended. You might be able to resolve your issue by exporting the following environment variables:
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
at Object.t.logAndThrowIfUnexpectedExitCode (/home/matt/.vscode-server/extensions/amazonwebservices.aws-toolkit-vscode-1.13.0/dist/extension.js:2:509696)
at Object.<anonymous> (/home/matt/.vscode-server/extensions/amazonwebservices.aws-toolkit-vscode-1.13.0/dist/extension.js:2:6981372)
at Generator.next (<anonymous>)
at o (/home/matt/.vscode-server/extensions/amazonwebservices.aws-toolkit-vscode-1.13.0/dist/extension.js:2:6980797)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
2020-09-21 16:32:13 [ERROR]: An error occurred while deploying a SAM Application. Check the logs for more information by running the "View AWS Toolkit Logs" command from the Command Palette.
2020-09-21 16:36:16 [INFO]: Successfully sent a telemetry batch of 11
To Reproduce
Expected behavior
I expect deployment to succeed as per running the SAM CLI in a WSL2 terminal window.
Screenshots
N/A
Desktop (please complete the following information):
OS: Linux x64 4.19.128-microsoft-standard Visual Studio Code Version: 1.49.1 AWS Toolkit Version: 1.13.0 Ubuntu 18.04 WSL2 sam --version SAM CLI, version 1.2.0
Additional context
N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
some more information. I have replaced my ~/.local/bin/sam with a fake shell script which calls the real sam. I captured the environment variables.
When running the problematic deploy which is after the
sam packagecommand - the only Environment variables are:Prior to the deployment, toolkit runs a
sam --info, and asam buildwhich both have all the correct variables which is why it doesn’t fail earlier. It is like toolkit has removed them all which i am not sure should be expected behavior.That looks like the problem.
https://github.com/aws/aws-toolkit-vscode/issues/1300 appears to be a filesystem issue whereas this issue looks related to environment variables.