astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.6k stars 466 forks source link

Lock Files Aren't Updated After Creation #1219

Closed justuswolff-audit closed 2 months ago

justuswolff-audit commented 2 months ago

Steps to Reproduce

rye init
rye add --optional=additional_1 numpy   
rye add --optional=additional_2 pandas 
rye lock --all-features
rye lock --features additional_1

Expected Result

Lock file is updated with reduced dependencies.

Actual Result

After the last command, both lock files aren't updated and remain like after rye lock --all-features:

# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
#   pre: false
#   features: []
#   all-features: true
#   with-sources: false
#   generate-hashes: false
#   universal: false

-e file:.
numpy==2.0.0
    # via pandas
    # via test-dir
pandas==2.2.2
    # via test-dir
python-dateutil==2.9.0.post0
    # via pandas
pytz==2024.1
    # via pandas
six==1.16.0
    # via python-dateutil
tzdata==2024.1
    # via pandas

However, after deleting the lock files and running rye lock --features additional_1 again, they are updated:

# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
#   pre: false
#   features: ["additional_1"]
#   all-features: false
#   with-sources: false
#   generate-hashes: false
#   universal: false

-e file:.
numpy==2.0.0
    # via test-dir

Version Info

rye 0.36.0 commit: 0.36.0 (12c024c7c 2024-07-07) platform: macos (aarch64) self-python: cpython@3.12.1 symlink support: true uv enabled: true

Stacktrace

No response

justuswolff-audit commented 2 months ago

Is this intended behaviour?

justuswolff-audit commented 2 months ago

As @bluss mentioned on Discord rye lock --reset --features additional_1 solves this issue. The --reset flag isn't mentioned in the docs though, is that something worth adding?

justuswolff-audit commented 2 months ago

rye sync -h provides all the neccessary information