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

Compare registry values to $INSTDIR before removing keys #684

Merged
merged 6 commits into from
Jun 27, 2023

Conversation

marcoesters
Copy link
Contributor

Description

The current uinstaller relies on values set during compile time to delete registry keys. Changes to the registry after the installation will not be taken into account when performing the uninstallation.

This PR scans the registry during uninstallation and deletes the entries that can be directly tied to the installation through $INSTDIR.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@marcoesters marcoesters requested a review from a team as a code owner June 15, 2023 20:42
@marcoesters marcoesters marked this pull request as draft June 15, 2023 20:42
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jun 15, 2023
@marcoesters marcoesters changed the title Do not replace NSIS predefines Compare registry values to $INSTDIR before removing keys Jun 15, 2023
@marcoesters marcoesters marked this pull request as ready for review June 15, 2023 22:43
@jaimergp
Copy link
Contributor

I like this better than what we have right now, but I wonder if we should pursue #588 after this. That'd mean replacing the logic in NSIS with the logic in conda-standalone (aka conda init), for both installation and uninstallation.

This way we make constructor more conda-agnostic. Of course, outside the scope of this PR.

@@ -1185,10 +1187,36 @@ Section "Uninstall"
# carefully. More info at https://docs.conda.io/projects/conda/en/latest/user-guide/troubleshooting.html#solution
System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_DLL_SEARCH_MODIFICATION_ENABLE", "1").r0'

# Read variables the uninstaller needs from the registry
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, this block will search the registry for two variables:

  • INSTALLER_NAME_FULL
  • INSTALLER_VERSION

These were previously assumed to be constant and would have used the hardcoded values at install time (${NAME} [used in line 65] and ${VERSION}, respectively).

However we are now saying that this might not be always the case. Could you elaborate under what circumstances this is true? e.g. updating Anaconda in place but not updating the registry keys (or not deleting the old ones before adding the new ones)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this logic allows the uninstaller to run for other conda installations if needed, I don't know if that's a bug or a feature 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this logic allows the uninstaller to run for other conda installations if needed, I don't know if that's a bug or a feature 😬

That is already possible. The changes in this PR will, however, conduct checks to make sure the deletion is performed consistently on the file system and the registry.

There is another, admittedly nice, application: if you install the same Miniconda/Miniforge version twice, installation 2 will overwrite the registry keys of number 1. If you then run the uninstaller of number 1, it will delete the keys of number 2.

${If} $0 == "$INSTDIR"
DeleteRegKey SHCTX "Software\Python\PythonCore\${PY_VER}"
${EndIf}
StrCpy $R0 "SOFTWARE\Python\PythonCore"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is easier to understand, I think. Basically we don't want to assume that the base Python is still the same version. However, is this updated when conda updates the python package in base? I don't remember seeing code for this 🤔 It would still be the same path, so it would work, but maybe the metadata is outdated when it comes to the reported version in the registry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also prevents issues in cross-installer usage, as described in my other comment.

I do not think that conda updates the registry when python is updated, which it should probably do.

Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
@jaimergp jaimergp mentioned this pull request Jun 19, 2023
31 tasks
@marcoesters marcoesters merged commit 247f93a into conda:main Jun 27, 2023
14 of 15 checks passed
@marcoesters marcoesters deleted the uninstaller-registry branch June 27, 2023 15:37
@github-actions github-actions bot added the locked [bot] locked due to inactivity label Jun 27, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed [bot] added once the contributor has signed the CLA locked [bot] locked due to inactivity
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants