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

Add uninstall subcommand #112

Merged
merged 70 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
90fadd4
Add uninstall subcommand.
marcoesters Sep 26, 2024
7a4d162
Add support for removing environment directories
marcoesters Sep 26, 2024
b4e7eb3
Create _is_subdir function
marcoesters Oct 2, 2024
ac8e86f
Specify which .condarc files to remove
marcoesters Oct 2, 2024
1526e7e
Clean parent directories of config files
marcoesters Oct 2, 2024
db47628
Rename ambiguous --clean to --conda-clean
marcoesters Oct 2, 2024
a30ba13
Add doc strings
marcoesters Oct 2, 2024
562b4a1
Clarify use of user and home in --remove-condarcs
marcoesters Oct 2, 2024
5ab526b
Use target path to detect Windows reg keys
marcoesters Oct 7, 2024
2449882
Improve HKEY handling
marcoesters Oct 8, 2024
a70059e
Do not support environment directories (menuinst may cause problems
marcoesters Oct 9, 2024
b81fd1a
Run menuinst separately from conda remove
marcoesters Oct 9, 2024
4d1a801
Add support for environments directories
marcoesters Oct 10, 2024
526cafc
Determine base prefix for menuinst
marcoesters Oct 11, 2024
93bc961
Use CONDA_ROOT_PREFIX instead of MENUINST_BASE_PREFIX
marcoesters Oct 17, 2024
b8b1b51
Merge branch 'main' of github.com:conda/conda-standalone into uninsta…
marcoesters Nov 1, 2024
ca69e06
Change homedir to Path.home()
marcoesters Nov 1, 2024
5548c81
Replace deprecated native_path_to_unix with win_path_to_unix
marcoesters Nov 4, 2024
70caa8f
Remove empty parent directories of pkgs_dirs and cache directories
marcoesters Nov 5, 2024
dc88b7b
Consolidate parent removal functions
marcoesters Nov 5, 2024
9161f57
Add tests
marcoesters Nov 7, 2024
023612f
Fix sentinel string for csh and tcsh
marcoesters Nov 7, 2024
736fa6d
Remove pkgs directory when only urls files are present
marcoesters Nov 7, 2024
2684f52
Check that parent directories are removed for init reverse tests
marcoesters Nov 7, 2024
dba344e
Merge branch 'main' of github.com:conda/conda-standalone into uninsta…
marcoesters Nov 7, 2024
74b22e2
Unset CONDA_ROOT_PREFIX during environment removal is root prefix is …
marcoesters Nov 8, 2024
0201b2c
Pre-create directories for menuinst on Windows
marcoesters Nov 9, 2024
0deff77
Force mocking user cache directory
marcoesters Nov 11, 2024
6ee8519
Skip LongPathsEnabled registry key
marcoesters Nov 11, 2024
ecef02a
Add conda to recipe test requirements
marcoesters Nov 11, 2024
9901c7a
Update documentation
marcoesters Nov 11, 2024
3f63e8c
Replace deprecated List type
marcoesters Nov 11, 2024
a4fc669
Add news file
marcoesters Nov 13, 2024
f19878c
Interpret conda.exe -m as conda.exe python -m to call run_plan_elevated
marcoesters Nov 13, 2024
9e98e72
Use sudo where needed for test_uninstallation_remove_condarcs
marcoesters Nov 13, 2024
fd131ef
Add a note that some files may be left behind with sudo
marcoesters Nov 13, 2024
43e8e21
Add missing XDG_DATA_HOME location for Linux shortcuts
marcoesters Nov 13, 2024
d882895
Convert path into string for init reverse plans
marcoesters Nov 13, 2024
684640c
Use different condarc locations for sudo and non-sudo runs
marcoesters Nov 14, 2024
615b96c
Do not write directly into /root
marcoesters Nov 14, 2024
d1f1f7e
Always write parents on mkdir
marcoesters Nov 14, 2024
e4f8031
Catch PermissionError on exists for /root/.condarc
marcoesters Nov 14, 2024
ac7072f
Use sudo -E
marcoesters Nov 14, 2024
2fc1017
Instruct to use sudo -E in README
marcoesters Nov 14, 2024
44ec212
Create wrapper function to run uninstaller in tests
marcoesters Nov 14, 2024
a9b3799
Make uninstall a subcommand of constructor
marcoesters Nov 14, 2024
f75a5ec
Use removeprefix
marcoesters Nov 18, 2024
ef04ccf
Check for directory before checking for file/symlink
marcoesters Nov 18, 2024
c817c49
Ensure that ON_CI=False for CI="0"
marcoesters Nov 18, 2024
e5550e5
Patch HOMEDRIVE and HOMEPATH
marcoesters Nov 18, 2024
43dfc51
Use conda environment fixtures
marcoesters Nov 18, 2024
03d3973
Add test_uninstallation_keep_config_dir
marcoesters Nov 18, 2024
07f55ff
Set MENUINST_BASE_PREFIX for menuinst test
marcoesters Nov 19, 2024
2426e49
Simplify _is_subdir function
marcoesters Nov 19, 2024
75f64fe
Warn about limited softlink support
marcoesters Nov 19, 2024
cdd46cc
Do not resolve paths in _remove_config_file_and_parents
marcoesters Nov 19, 2024
91f6fb1
Do not use conda fixtures for menuinst tests
marcoesters Nov 19, 2024
9a6221a
Elaborate on lack of symlink support.
marcoesters Nov 19, 2024
8647a1b
Rename --remove-caches to --remove-conda-caches
marcoesters Nov 19, 2024
457f11e
Expand variables for args.prefix
marcoesters Nov 19, 2024
f45c70c
Ensure that mutually exclusive group is required without a subcommand
marcoesters Nov 19, 2024
496992d
Clarify how --prefix is enforced
marcoesters Nov 19, 2024
ab47b6c
Remove empty parents only when created by conda
marcoesters Nov 19, 2024
16b13c6
Return earlier when removing parents of config files
marcoesters Nov 20, 2024
e41d1e3
Do not resolve uninstall_prefix
marcoesters Nov 22, 2024
90996a7
Remove notices cache with package caches
marcoesters Nov 22, 2024
67f8f79
Use XDG-style conventions for constructor uninstall CLI arguments
marcoesters Nov 25, 2024
854220d
Fix typo in README
marcoesters Nov 25, 2024
404d331
Apply suggestions from code review
marcoesters Nov 26, 2024
ad1c8d8
Update src/entry_point.py
marcoesters Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 47 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,64 @@ It also adds new subcommands not available on the regular `conda`:
This subcommand is mainly used by the installers generated with `constructor`.

```bash
$ conda.exe constructor --help
usage: conda.exe constructor [-h] --prefix PREFIX [--extract-conda-pkgs] [--extract-tarball] [--make-menus [PKG_NAME ...]] [--rm-menus]
usage: conda.exe constructor [-h] [--prefix PREFIX] [--num-processors N]
[--extract-conda-pkgs | --extract-tarball | --make-menus [PKG_NAME ...] | --rm-menus]
{uninstall} ...

constructor helper subcommand

optional arguments:
positional arguments:
{uninstall}

options:
-h, --help show this help message and exit
--prefix PREFIX path to the conda environment to operate on
--num-processors N Number of processors to use with --extract-conda-pkgs. Value must be int between 0 (auto) and the
number of processors. Defaults to 3.
--extract-conda-pkgs extract conda packages found in prefix/pkgs
--extract-tarball extract tarball from stdin
--make-menus [PKG_NAME ...]
create menu items for the given packages; if none are given, create menu items for all packages in the environment specified by --prefix
create menu items for the given packages; if none are given, create menu items for all packages
in the environment specified by --prefix
--rm-menus remove menu items for all packages in the environment specified by --prefix
```

### `conda.exe constructor uninstall`

This subcommand can be used to uninstall a base environment and all sub-environments, including
entire Miniconda/Miniforge installations.
It is also possible to remove environments directories created by `conda create`. This feature is
useful if `envs_dirs` is set inside `.condarc` file.

There are several options to remove configuration and cache files:

```bash
$ conda.exe constructor uninstall [-h] --prefix PREFIX [--conda-clean] [--remove-condarcs {user,system,all}]
[--remove-caches]
```

- `--prefix` (required): Path to the conda directory to uninstall.
- `--remove-condarcs {user,system,all}`: Remove all .condarc files. `user` removes the files
inside the current user's home directory and
`system` removes all files outside of that directory.
Not recommended when multiple conda installations are on
the system or when running on an environments directory.
- `--remove-caches`: Remove all cache directories created by conda. This includes the `.conda`
directory inside `HOME`/`USERPROFILE`. Not recommended when multiple conda
installations are on the system or when running on an environments directory.
- `--conda-clean`: Run `conda --clean --all` to remove package caches outside the installation
directory. This is only useful when `pkgs_dirs` is set in a `.condarc` file.
Not recommended with multiple conda installations when softlinks are enabled.

> [!IMPORTANT]
> Use `sudo -E` if removing system-level configuration files requires superuser privileges.
> `conda` relies on environment variables like `HOME` and `XDG_CONFIG_HOME` when detecting
> configuration files, which may be overwritten with just `sudo`.
> This can cause files to be left behind.

> [!WARNING]
> Support for softlinks is still limited.
jaimergp marked this conversation as resolved.
Show resolved Hide resolved

### `conda.exe python`

This subcommand provides access to the Python interpreter bundled in the conda-standalone
Expand Down
20 changes: 20 additions & 0 deletions news/112-add-uninstall-subcommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Enhancements

* Add `uninstall` subcommand, which uninstalls all environments inside a prefix and reverses
`conda init` commands. It also for deleting cache directories and configuration files. (#112)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
3 changes: 2 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ requirements:

test:
requires:
- pytest
- conda
- menuinst >={{ menuinst_lower_bound }}
- pytest
- ruamel.yaml
source_files:
- tests
Expand Down
Loading
Loading