Skip to content

Implement conda self reset - #6

Merged
jaimergp merged 1 commit into
conda:mainfrom
soapy1:reset-self
Jun 24, 2025
Merged

Implement conda self reset#6
jaimergp merged 1 commit into
conda:mainfrom
soapy1:reset-self

Conversation

@soapy1

@soapy1 soapy1 commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@jaimergp

Copy link
Copy Markdown
Member

Instead of a hardcoded list, I think we can use PrefixGraph on the installed conda to get its dependency tree and keep that only. Then do the same for all extra conda plugins that might be found in the environment, depending on the flag passed in CLI (with plugins or without plugins).

However this will not respect the installer history well, so maybe we just need to get the tree corresponding to the first revision of the history file?

@soapy1

soapy1 commented Jun 19, 2025

Copy link
Copy Markdown
Contributor Author

However this will not respect the installer history well, so maybe we just need to get the tree corresponding to the first revision of the history file?

hmmm, I think I'm not quite sure what this command is suppose to do. I think there are 2 approaches for what it means to reset.

1. remove all packages except the bare minimum that should exist in the base environment

With this option there are some important things to note:

  • the definition of what the bare minimum set of packages is must exist somewhere. It's not clear to me who has ought to have this responsibility
  • with this approach the reset action can be added to the history. So, persumably a user could roll back to the state before the reset

2. roll back the environment to an older state

With this option there are some important things to note:

  • it isn't always obvious which revision to roll back to. For users who have a really old conda, their revision 0 will be a very old environemnt.
  • rolling back to a revision means that conda developers will not be able to change the set of default base environment packages. Changing the default set of base packages might be a bad idea anyway?
  • this option will require some finessing if history is meant to be able to be preserved so that users can roll back to a state before resetting.

IMO, I think, option (1) is a better option, provided that we can sort out who's responsibility it is to define the bare minimum set of packages that must exist in the base environment.

@jaimergp

Copy link
Copy Markdown
Member

I think we should go with this strategy, given the following assumptions:

  • If the user needs conda reset they are already in trouble, so we cannot afford to be too lenient with the requirements. Let's aim for the most basic reset possible: just installing conda.
  • There's a chance that conda is so broken that conda reset doesn't even run. Let's defend that with good docs and exception handling.

If we are optimistic though, it might be able to run and in that case we should simply install the latest conda available (from the channel where conda is coming from), along with the essential dependencies. Plugins should probably be left out for now (a flag might be added in the future, but if the problem was introduced by a plugin installation, that's asking for more trouble).

However, if conda reset fails to run (but the subcommand system still works), we could print a message with instructions to download conda-standalone and run the equivalent logic there. Which means we also need conda-standalone reset (perhaps with a patch to require a flag like --installation-path because sys.prefix won't be valid in standalone mode).

@soapy1
soapy1 marked this pull request as ready for review June 24, 2025 15:33
@jaimergp
jaimergp merged commit 17d168f into conda:main Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants