-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'[IndexError] list index out of range' on poetry install in Docker if packages is specified #1899
Comments
Not sure why this line
comes before
Seems like this should have been in the other order, to give a more meaningful error. |
Can report I am seeing the same error on EDIT: my issue was I was not correctly specifying the
|
Another workaround/hack would just create a package empty folder with __init__.py so that poetry can find it. This will not break the cache, and one will still be able to copy over project/package files after requirements are installed. For instance if app root is /usr/src/app/ and with local package name package : RUN mkdir -p /usr/src/app/package
RUN touch /usr/src/app/package/__init__.py |
My current workaround for this is as follows: # Only copying these files here in order to take advantage of Docker cache. We only want the
# next stage (poetry install) to run if these files change, but not the rest of the app.
COPY pyproject.toml poetry.lock ./
# Currently poetry install is significantly slower than pip install, so we're creating a
# requirements.txt output and running pip install with it.
# Follow this issue: https://github.com/python-poetry/poetry/issues/338
# Setting --without-hashes because of this issue: https://github.com/pypa/pip/issues/4995
RUN poetry config virtualenvs.create false \
&& poetry export --without-hashes -f requirements.txt --dev \
| poetry run pip install -r /dev/stdin \
&& poetry debug
COPY . ./
# Because initially we only copy the lock and pyproject file, we can only install the dependencies
# in the RUN above, as the `packages` portion of the pyproject.toml file is not
# available at this point. Now, after the whole package has been copied in, we run `poetry install`
# again to only install packages, scripts, etc. (and thus it should be very quick).
# See this issue for more context: https://github.com/python-poetry/poetry/issues/1899
RUN poetry install --no-interaction
# We're setting the entrypoint to `poetry run` because poetry installed entry points aren't
# available in the PATH by default, but it is available for `poetry run`
ENTRYPOINT ["poetry", "run"] Hope this helps someone. |
I have the same issue when I try to call poetry export, but there is no workaroud (--no-root is not an option for export).
|
@gimlidc please update to |
Deleting |
Duplicate #1301. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
A common technique when creating a Dockerfile is to copy pyproject.toml and poetry.lock, then running poetry install.
Like so:
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:
One can get around this by installing with
--no-root
flag:RUN poetry install --no-dev --no-root
Related: #1247
The text was updated successfully, but these errors were encountered: