0

I'm running a local install of readthedocs 5.1, and I'm building a project by running python manage.py update_repos. I get the following error:

Traceback (most recent call last):
  File "/readthedocs.org/readthedocs/projects/tasks.py", line 767, in run_build
    outcomes = self.build_docs()
  File "/readthedocs.org/readthedocs/projects/tasks.py", line 1160, in build_docs
    outcomes['html'] = self.build_docs_html()
  File "/readthedocs.org/readthedocs/projects/tasks.py", line 1178, in build_docs_html
    success = html_builder.build()
  File "/readthedocs.org/readthedocs/doc_builder/backends/mkdocs.py", line 285, in build
    bin_path=self.python_env.venv_bin()
  File "/readthedocs.org/readthedocs/doc_builder/base.py", line 140, in run
    return self.build_env.run(*args, **kwargs)
  File "/readthedocs.org/readthedocs/doc_builder/environments.py", line 642, in run
    return super().run(*cmd, **kwargs)
  File "/readthedocs.org/readthedocs/doc_builder/environments.py", line 424, in run
    return self.run_command_class(cls=self.command_class, cmd=cmd, **kwargs)
  File "/readthedocs.org/readthedocs/doc_builder/environments.py", line 648, in run_command_class
    return super().run_command_class(*cmd, **kwargs)
  File "/readthedocs.org/readthedocs/doc_builder/environments.py", line 496, in run_command_class
    raise BuildEnvironmentWarning(msg)
readthedocs.doc_builder.exceptions.BuildEnvironmentWarning: Command /readthedocs.org/user_builds/openwhisk/envs/latest/bin/python -m mkdocs build --clean --site-dir _build/html --config-file mkdocs.yml failed:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/readthedocs.org/user_builds/openwhisk/envs/latest/lib/python3.6/site-packages/mkdocs/__main__.py", line 202, in <module>
    cli()
  File "/readthedocs.org/user_builds/openwhisk/envs/latest/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/readthedocs.org/user_builds/openwhisk/envs/latest/lib/python3.6/site-packages/click/core.py", line 760, in main
    _verify_python3_env()
  File "/readthedocs.org/user_builds/openwhisk/envs/latest/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

[27/May/2020 19:38:14] readthedocs.doc_builder.environments:585[3088]: INFO (Build) [openwhisk:latest] Build finished

I'm running readthedocs inside a Debian python container, but setting these env vars from bash using export doesn't work.

luds
  • 331
  • 2
  • 13
  • 1
    FYI for those wondering "why python3 can error out because of something small like unset locale (i.e. env vars `LANG`, `LC_ALL`)" --> read [PEP 538](https://www.python.org/dev/peps/pep-0538/) and the related [PEP 540](https://www.python.org/dev/peps/pep-0540/). The error appears to only be an issue for python 3.0 to 3.6 because PEP 538 fixes the issues for python >= 3.7. – Trevor Boyd Smith Oct 18 '21 at 14:41
  • Does this answer your question? [Encoding issue with python3 and click package](https://stackoverflow.com/questions/32234393/encoding-issue-with-python3-and-click-package) – Trevor Boyd Smith Oct 18 '21 at 15:26

1 Answers1

0

You need to set these environment variables in the readthedocs project settings under "Admin" -> "Environment Variables".

LC_ALL=C.UTF-8
LANG=C.UTF-8
luds
  • 331
  • 2
  • 13