whythawk / full-stack-fastapi-postgresql

Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Nuxt3, Docker, automatic HTTPS and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Poetry problems

Miskinis opened this issue · comments

Any attempt at using poetry add, causes a The lock file is not compatible with the current version of Poetry error when building docker.
I'm using poetry 1.4.0

That happens when you edit the pyproject.toml file without using poetry itself. The way to fix this is to delete your virtual environment, delete the lock file, and then poetry install. That can have the impact of updating or changing library versions and causing other effects, so ... if you can reverse the changes you made in the toml file, do that first and make sure to use Poetry to make adjustments.

EDIT: the lock and toml files get out of alignment when you don't use Poetry to make changes.

I didn't edit pyproject.toml manually, I used poetry add, but since my poetry is 1.4.0 and container's is 1.1, it's probably incompatible.
I fixed it by adding RUN pipx upgrade poetry to backend docker file, right before it executes poetry install

By the way, deleting lock file doesn't fix the problem. If it stays deleted, then docker complains about not finding dependencies for pytest-cov and if I regenerate the lock, I end up where I started.

Yeah, if you delete the lock file you need to re-run poetry install to regenerate it. The version mismatch may have caused your problems, though.

Just to add a reference to this issue for future search: https://inboard.bws.bio/docker#docker-and-poetry

Inboard now uses Hatch for Python dependency management and packaging. Poetry 1.1 was used before Hatch, and Poetry 1.1 is still included in the Docker images for backwards compatibility. If you have a downstream project using the inboard Docker images with a newer version of Poetry, you can add RUN pipx upgrade poetry or RUN pipx install poetry>1.2 --force to your Dockerfile to upgrade Poetry for your project.