Inconsistent behavior in a virtual project with empty dependencies
Steps to Reproduce
- Create a virtual project using
rye init --virtual virtual_project. - Go into the virtual project directory with
cd virtual_project. - Run sync using
rye sync. - Add any dependency using
rye add. For example,rye add aiohttp. - Remove the installed dependency with
rye remove aiohttp. - Run
rye listto list installed dependencies.
Expected Result
The command rye list shouldn't display anything since we remove the only dependency. And no dependency should be listed in pyproject.toml, requirements.lock and requirements-dev.lock.
Actual Result
There is no dependency listed in pyproject.toml, requirements.lock and requirements-dev.lock. However, the command rye list still shows the dependencies of the removed package.
What's more, if you try to add other package now, you will find that rye shows the record of removing the dependencies of the previously removed packages. This means that rye didn't remove them but kept them in the virtual environment until the new package is added.
I personally guess it might be an upstream problem from uv when dealing with empty dependencies as it shows the following warning when I remove the last dependency. And such a warning also appears when you first did rye sync on the virtual project.
warning: Requirements file requirements-dev.lock does not contain any dependencies
No requirements found (hint: use `--allow-empty-requirements` to clear the environment)
Version Info
rye 0.39.0 commit: 0.39.0 (bf3ccf818 2024-08-21) platform: linux (x86_64) self-python: [email protected] symlink support: true uv enabled: true
Stacktrace
No response