-vvv option).The current 1.0.0 beta release crashes when running poetry with --help or without arguments:
$ poetry
Poetry version 1.0.0b1
USAGE
[UnicodeEncodeError]
'ascii' codec can't encode character '\xa0' in position 30: ordinal not in range(128)
I've only seen this in a Docker container, it works correctly on my desktop.
This Dockerfile reproduces it:
FROM ubuntu:bionic-20190912.1
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3.6 python3-pip python3-venv && \
pip3 install setuptools wheel && \
pip3 install poetry==1.0.0b1
Steps:
./Dockerfile in a directory containing the above$ sudo docker build -t poetry-unicode-issue .$ sudo docker run poetry-unicode-issue poetry --help -vvv
Poetry version 1.0.0b1
USAGE
[UnicodeEncodeError]
'ascii' codec can't encode character '\xa0' in position 22: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/clikit/console_application.py", line 132, in run
status_code = command.handle(parsed_args, io)
File "/usr/local/lib/python3.6/dist-packages/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/usr/local/lib/python3.6/dist-packages/clikit/api/command/command.py", line 173, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "/usr/local/lib/python3.6/dist-packages/clikit/handler/help/help_text_handler.py", line 29, in handle
usage.render(io)
File "/usr/local/lib/python3.6/dist-packages/clikit/ui/help/abstract_help.py", line 31, in render
layout.render(io, indentation)
File "/usr/local/lib/python3.6/dist-packages/clikit/ui/layout/block_layout.py", line 42, in render
element.render(io, self._indentations[i] + indentation)
File "/usr/local/lib/python3.6/dist-packages/clikit/ui/components/labeled_paragraph.py", line 70, in render
+ '
'"
File "/usr/local/lib/python3.6/dist-packages/cleo/io/io_mixin.py", line 55, in write
super(IOMixin, self).write(string, flags)
File "/usr/local/lib/python3.6/dist-packages/clikit/api/io/io.py", line 58, in write
self._output.write(string, flags=flags)
File "/usr/local/lib/python3.6/dist-packages/clikit/api/io/output.py", line 61, in write
self._stream.write(to_str(formatted))
File "/usr/local/lib/python3.6/dist-packages/clikit/io/output_stream/stream_output_stream.py", line 24, in write
self._stream.write(string)
The default encoding seems to be detected correctly:
$ python3 -c 'import sys; print(sys.getdefaultencoding())'
utf-8
This is not a poetry issue. The problem here is the container locale.
$ docker run --rm -it ubuntu:bionic-20190912.1 locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
When the default "C" (POSIX) locale is used, python 3 does not like it. See https://bugs.python.org/issue19846 for more information.
If you want to keep using python 3.6, then you can add this to your Dockerfile to get it working.
ENV LANG C.UTF-8
As per PEP-538 and PEP-540, python 3.7 will work out of the box.
Ah OK, thanks for that.
Most helpful comment
This is not a poetry issue. The problem here is the container locale.
When the default "C" (POSIX) locale is used, python 3 does not like it. See https://bugs.python.org/issue19846 for more information.
If you want to keep using python 3.6, then you can add this to your
Dockerfileto get it working.As per PEP-538 and PEP-540, python 3.7 will work out of the box.