poetry icon indicating copy to clipboard operation
poetry copied to clipboard

`poetry install` exit code 0 (success) even if readme file does not exist and fails to install the package

Open roy-ht opened this issue 1 year ago • 6 comments

  • Poetry version: Poetry (version 1.7.0)
  • Python version: Python: 3.10.9
  • OS version and name: Ubuntu 22.04
  • pyproject.toml:
[tool.poetry]
name = "test"
version = "1.0.0"
readme = "README_does_not_exist"
authors = ["xxx <[email protected]>"]
description = ""

[tool.poetry.dependencies]
python = ">=3.10,<3.11"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
  • [x] I am on the latest stable Poetry version, installed using a recommended method.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] I have consulted the FAQ and blog for any relevant entries or release notes.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

with Poetry 1.6.1, poetry install command fails with exit code != 0:

❯ poetry161 install
Installing dependencies from lock file

[Errno 2] No such file or directory: '/home/jovyan/repo/sarasvati/temp/README_does_not_exist'

but Poetry 1.7.0 do not fail:

❯ poetry install   
Installing dependencies from lock file

Installing the current project: test (1.0.0)
The current project could not be installed: [Errno 2] No such file or directory: '/home/jovyan/repo/sarasvati/temp/README_does_not_exist'
If you do not want to install the current project use --no-root

I guess this behavior was introduced by https://github.com/python-poetry/poetry/pull/8369 .

In daily development, it's ok, one can see the warning messages.

But in my usecase, poetry install in Dockerfile, docker build doesn't fail if i forget to copy README like COPY README.md.

This result is very confusing, and I expect to return failure exit code if attempting to install package was failed.

Thanks! :)

roy-ht avatar Nov 09 '23 03:11 roy-ht

So with Poetry 1.6, poetry install fails if the readme is missing, but does not fail if the complete package is missing. Quite inconsistent, isn't it?

Poetry 1.7 does not fail, but prints a warning in both cases. I agree that it would be better if it failed, but I think we can only change this after we have a "non-package" mode (cf https://github.com/python-poetry/poetry/issues/1132#issuecomment-1793690699) because there are a lot of users who do not want it to fail.

radoering avatar Nov 10 '23 16:11 radoering

but I think we can only change this after we have a "non-package" mode (cf https://github.com/python-poetry/poetry/issues/1132#issuecomment-1793690699) because there are a lot of users who do not want it to fail.

It’s not a critical issue and i agree with your plan. Thanks @radoering !

roy-ht avatar Nov 15 '23 00:11 roy-ht

I can confirm this issues as well (poetry 1.7.1). Docker build with poetry -n install --only-root silently failed due to missing README.md. I consider this a clear bug. Especially beacuse earlier versions errored correctly (error code 1 thown by poetry 1.5.1 here.)

th0ger avatar Nov 27 '23 11:11 th0ger

Just his this today, I also forgot to COPY the README.md into our Dockerfile. The poetry install command threw a warning, but still gave a 0 error code (which didn't crash the Docker build):

Installing the current project: <redacted>
Warning: The current project could not be installed: [Errno 2] No such file or directory: '/README.md'
If you do not want to install the current project use --no-root.
If you want to use Poetry only for dependency management but not for packaging, you can set the operating mode to "non-package" in your pyproject.toml file.
In a future version of Poetry this warning will become an error!

The last line is promising 🤓 : In a future version of Poetry this warning will become an error!.


Imo since the failure is catastrophic (image build succeeds, but fails at runtime since installation didn't actually happen), the default behavior should definitely be an error, not a warning.

there are a lot of users who do not want it to fail.

I can understand this. Maybe an alternate solution is for poetry to just neglect the missing readme metadata and still proceed with the installation, instead of stopping the install entirely.

jamesbraza avatar Mar 08 '24 22:03 jamesbraza

Hello, I just had this exact same problem when building a Docker image: basically poetry is silently failing if the readme is not there and it breaks the container even if the build is successful.

If poetry does not build the project successfully there should definitely be an error: I don't see any reasonable scenario in which the build is broken, but the tool returns success.

lorenzophys avatar Jun 19 '24 10:06 lorenzophys

I'm not a maintainer, but my understanding is that this is supposed to become a hard error with Poetry 2.0: https://github.com/python-poetry/poetry/issues/9136 and https://github.com/python-poetry/poetry/issues/9448

ilyagr avatar Jun 20 '24 00:06 ilyagr