'[IndexError] list index out of range' on poetry install in Docker if packages is specified
See original GitHub issue- 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: python:3.7-alpine3.11 (Docker)
- Poetry version: 1.0.2
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/kbakk/0811ab3d4a7e90f3141c2c2d4ac2be3e
Issue
A common technique when creating a Dockerfile is to copy pyproject.toml and poetry.lock, then running poetry install.
Like so:
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-dev
# then, add the rest of the project to only run
# poetry install when pyproject.toml/poetry.lock changes
COPY . /app
However, if the project is contains packages (see example pyproject.toml linked above), poetry will fail to find these, as they hasn’t been copied over yet, and throw error:
[IndexError]
list index out of range
Traceback (most recent call last):
File "/root/.poetry/lib/poetry/_vendor/py3.7/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "/root/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/root/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py", line 171, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "/root/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/command.py", line 92, in wrap_handle
return self.handle()
File "/root/.poetry/lib/poetry/console/commands/install.py", line 72, in handle
builder = EditableBuilder(self.poetry, self._env, NullIO())
File "/root/.poetry/lib/poetry/masonry/builders/builder.py", line 68, in __init__
includes=self._package.include,
File "/root/.poetry/lib/poetry/masonry/utils/module.py", line 72, in __init__
source=package.get('from'),
File "/root/.poetry/lib/poetry/masonry/utils/package_include.py", line 15, in __init__
self.check_elements()
File "/root/.poetry/lib/poetry/masonry/utils/package_include.py", line 37, in check_elements
root = self._elements[0]
One can get around this by installing with --no-root
flag:
RUN poetry install --no-dev --no-root
Related: #1247
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Python Poetry Index Error – list index out of range
So far I've identified two things that you need to check. Credentials: If you are installing packages from a private repository, ...
Read more >Running Poetry install command gives error : list index out of ...
I am not sure if there is a simpler method for this: install pyenv https://github.com/pyenv/pyenv-installer. with pyenv run command.
Read more >Managing dependencies | Documentation - Poetry
Managing dependencies Dependency groups Poetry provides a way to organize your dependencies by groups. For instance, you might have dependencies that are ...
Read more >Bug #50691: cephadm: bootstrap fails with "IndexError: list ...
cephadm: bootstrap fails with "IndexError: list index out of range" during ... Running on a cleanly installed Debian 10.9 host with ceph/cephadm 16.2.3....
Read more >Python in VSCode: Running and Debugging
If you define project-specific settings in VSCode, the IDE creates a new file, .vscode/settings.json ... IndexError: list index out of range.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My current workaround for this is as follows:
Hope this helps someone.
Duplicate #1301.