"expected string or bytes-like object" on poetry install #3628
Description
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).
- OS version and name: based on official docker image
python:3.8-slim-buster
(see below for Dockerfile) - Poetry version: 1.1.4
- virtualenv version: 20.4.2
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/wichert/ba05b0505c24ee7c71c5d7deb2ac2cfe
Issue
When I run poetry install
in a private GitHub runner on an GHES installation I started getting an error (see further below for full output):
TypeError
expected string or bytes-like object
at /usr/local/lib/python3.8/site-packages/poetry/core/utils/helpers.py:24 in canonicalize_name
Debug output
Creating virtualenv amp-portal in /__w/backend/backend/amp-portal/.venv
Using virtualenv: /__w/backend/backend/amp-portal/.venv
Stack trace:
11 /usr/local/lib/python3.8/site-packages/clikit/console_application.py:131 in run
129│ parsed_args = resolved_command.args
130│
→ 131│ status_code = command.handle(parsed_args, io)
132│ except KeyboardInterrupt:
133│ status_code = 1
10 /usr/local/lib/python3.8/site-packages/clikit/api/command/command.py:120 in handle
118│ def handle(self, args, io): # type: (Args, IO) -> int
119│ try:
→ 120│ status_code = self._do_handle(args, io)
121│ except KeyboardInterrupt:
122│ if io.is_debug():
9 /usr/local/lib/python3.8/site-packages/clikit/api/command/command.py:163 in _do_handle
161│ if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
162│ event = PreHandleEvent(args, io, self)
→ 163│ self._dispatcher.dispatch(PRE_HANDLE, event)
164│
165│ if event.is_handled():
8 /usr/local/lib/python3.8/site-packages/clikit/api/event/event_dispatcher.py:22 in dispatch
20│
21│ if listeners:
→ 22│ self._do_dispatch(listeners, event_name, event)
23│
24│ return event
7 /usr/local/lib/python3.8/site-packages/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
87│ break
88│
→ 89│ listener(event, event_name, self)
90│
91│ def _sort_listeners(self, event_name): # type: (str) -> None
6 /usr/local/lib/python3.8/site-packages/poetry/console/config/application_config.py:141 in set_installer
139│
140│ poetry = command.poetry
→ 141│ installer = Installer(
142│ event.io,
143│ command.env,
5 /usr/local/lib/python3.8/site-packages/poetry/installation/installer.py:65 in __init__
63│ self._installer = self._get_installer()
64│ if installed is None:
→ 65│ installed = self._get_installed()
66│
67│ self._installed_repository = installed
4 /usr/local/lib/python3.8/site-packages/poetry/installation/installer.py:561 in _get_installed
559│
560│ def _get_installed(self): # type: () -> InstalledRepository
→ 561│ return InstalledRepository.load(self._env)
562│
3 /usr/local/lib/python3.8/site-packages/poetry/repositories/installed_repository.py:118 in load
116│ path = Path(str(distribution._path))
117│ version = distribution.metadata["version"]
→ 118│ package = Package(name, version, version)
119│ package.description = distribution.metadata.get("summary", "")
120│
2 /usr/local/lib/python3.8/site-packages/poetry/core/packages/package.py:51 in __init__
49│ Creates a new in memory package.
50│ """
→ 51│ super(Package, self).__init__(
52│ name,
53│ source_type=source_type,
1 /usr/local/lib/python3.8/site-packages/poetry/core/packages/specification.py:19 in __init__
17│ ): # type: (str, Optional[str], Optional[str], Optional[str], Optional[str], Optional[List[str]]) -> None
18│ self._pretty_name = name
→ 19│ self._name = canonicalize_name(name)
20│ self._source_type = source_type
21│ self._source_url = source_url
TypeError
expected string or bytes-like object
at /usr/local/lib/python3.8/site-packages/poetry/core/utils/helpers.py:24 in canonicalize_name
20│ _canonicalize_regex = re.compile("[-_]+")
21│
22│
23│ def canonicalize_name(name): # type: (str) -> str
→ 24│ return _canonicalize_regex.sub("-", name).lower()
25│
26│
27│ def module_name(name): # type: (str) -> str
28│ return canonicalize_name(name).replace(".", "_").replace("-", "_")
Dockerfile for base docker image
ARG DEBIAN_VERSION=buster
ARG PYTHON_VERSION=3.8
FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION}
ENV \
DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1
RUN set -x \
&& apt-get update \
&& apt-get install -yq --no-install-recommends libpq-dev build-essential sudo \
&& rm -rf /var/lib/apt/lists/*
RUN pip install poetry==1.1.4