Skip to content
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

uv sync --no-clean #4367

Merged
merged 4 commits into from
Jun 17, 2024
Merged

uv sync --no-clean #4367

merged 4 commits into from
Jun 17, 2024

Conversation

ibraheemdev
Copy link
Member

@ibraheemdev ibraheemdev commented Jun 17, 2024

Summary

Adds a --no-clean flag to uv sync that keeps extraneous installations. This is the default in uv run and uv add, but not in uv sync or uv remove. This means you need to run an explicit uv sync/remove to clean the virtual environment.

Could use some tests.

@ibraheemdev ibraheemdev added the preview Experimental behavior label Jun 17, 2024
@zanieb
Copy link
Member

zanieb commented Jun 17, 2024

I'm not sure I love the name. Are there some examples of the flag in other tools?

@ibraheemdev
Copy link
Member Author

ibraheemdev commented Jun 17, 2024

The name is from a Poetry proposal, although it was not accepted. Most other tools have the opposite default behavior, so I don't know of much prior art here.

@zanieb
Copy link
Member

zanieb commented Jun 17, 2024

I don't think we have a clear concept of "tracked" and it doesn't have a negative which follows our typical "no" prefix. I think a user could change the default sync behavior via configuration and want to opt-in to removal via the CLI and that should be natural.

Just to throw some ideas out....

  • --no-remove-untracked / --remove-untracked
  • --allow-untracked / --no-allow-untracked
  • --no-remove-extra-packages / --remove-extra-packages
  • --no-remove-unknown / --remove-unknown
  • --no-clean / --clean
  • --no-remove / --remove
  • --untracked <remove | warn | ignore>
  • --extra-packages <remove | warn | ignore>

@zanieb
Copy link
Member

zanieb commented Jun 17, 2024

@ibraheemdev can we separate fixing run and add so we can release without figuring out a name? Alternatively we can just use something and break it later if we want.

@ibraheemdev
Copy link
Member Author

ibraheemdev commented Jun 17, 2024

--clean and --no-clean are synonymous with commands from other tools (cargo clean, yarn cache clean), so I think that makes sense for now.

@zanieb
Copy link
Member

zanieb commented Jun 17, 2024

It's a little weird because it refers to the cache in those cases but the actual environment in this one. I'm fine to try it out though.

@ibraheemdev
Copy link
Member Author

There's also pdm sync --clean.

@ibraheemdev ibraheemdev changed the title uv sync --keep-untracked uv sync --no-clean Jun 17, 2024
@ibraheemdev ibraheemdev enabled auto-merge (squash) June 17, 2024 20:07
@zanieb
Copy link
Member

zanieb commented Jun 17, 2024

That's where I saw it :D

@ibraheemdev ibraheemdev merged commit a813a1d into main Jun 17, 2024
47 checks passed
@ibraheemdev ibraheemdev deleted the uv-sync-no-remove branch June 17, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants