question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while deploying SAM application using WSL2

See original GitHub issue

While 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:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mattgillardcommented, Sep 21, 2020

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 package command - the only Environment variables are:

AWS_SECRET_ACCESS_KEY=xx
PWD=/mnt/c/Users/matt/.vscode/extensions/ms-vscode-remote.remote-wsl-0.44.5
AWS_ACCESS_KEY=xx
AWS_SECRET_KEY=xx
AWS_ACCESS_KEY_ID=xx
SHLVL=1

Prior to the deployment, toolkit runs a sam --info, and a sam build which 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.

1reaction
justinmk3commented, Sep 21, 2020

https://github.com/aws/aws-toolkit-vscode/issues/1300 appears to be a filesystem issue whereas this issue looks related to environment variables.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to run sam cli on Windows Subsystem for Linux 2
I ran the commands brew tap aws/tap brew install aws-sam-cli. I thought they were supposed take care of installing the dependencies. – Alper....
Read more >
Installing the AWS SAM CLI - AWS Serverless Application Model
This section describes how to install the AWS SAM CLI on macOS, Windows, and Linux.
Read more >
FAQ's about Windows Subsystem for Linux - WSL
Find answers to frequently asked questions (FAQs) about the Windows Subsystem for Linux, such as 'What can I do with WSL?'.
Read more >
Lambda: using AWS SAM Local to test ... - marcesher.com
Installing on Windows. The instructions recommend installing with npm. That didn't work for me, giving me errors about file not found. I'm not ......
Read more >
How to Install Windows Subsystem for Linux (WSL2) on ...
Docker can run directly inside of WSL2 (a full Linux Kernel built by ... Once done, "Windows needs to reboot your PC to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found