dotnet / dotnet/cli-lab

dotnet-core-uninstall should not require admin permissions in a custom install location

Open
#267 3 comments 3 reactions 0 assignees View on GitHub
Area-Uninstall-Tool
Dominant language
C#
Stars
774
Forks
72
Avg merge
1d 23h
Merged PRs (30d)
2

Description

I'm running on MacOS (Mac M1, MacOS Ventura) and have all of my .NET SDKs installed in my user folder at `~/.dotnet`. I also have the following set in my `~/.profile` so builds and things run great.

```sh
export DOTNET_INSTALL_DIR="$HOME/.dotnet"
export DOTNET_ROOT="$HOME/.dotnet"
export PATH="$DOTNET_ROOT:$DOTNET_ROOT/tools:$PATH"
```

I can install the .NET SDK perfectly using the [`dotnet-install` script](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script).

When I run `dotnet-core-uninstall list`, it correctly sees `DOTNET_INSTALL_DIR` and lists my SDKs and runtimes.

However, when I try to `dotnet-core-uninstall remove` it tells me:

> `The current user does not have adequate privileges. See https://aka.ms/dotnet-core-uninstall-docs.`

All I see in the docs is "it requires admin permissions":

> The tool requires elevation to uninstall .NET SDKs and runtimes. Run the tool in an Administrator command prompt on Windows and with sudo on macOS. The dry-run and whatif commands don't require elevation.

It doesn't tell me _why_ and doesn't really make a ton of sense in this use case. It appears to [just check for admin permissions and fail out of hand, even if it really doesn't need them.](https://github.com/dotnet/cli-lab/blob/dbbc288e858c078ac7c5dc56a3e7579d79771391/src/dotnet-core-uninstall/Shared/Commands/UninstallCommandExec.cs#L43)

Would it be possible to maybe do one of these things...?

- Stop requiring admin by default
- Add a `--no-admin` or similar switch to allow bypassing that check
- Only check for admin permissions when it's time to modify something that actually might require admin

Alternatively, is there a document that explains what uninstalling a bundle on MacOS means so I could maybe script it? Is it just a matter of dropping the `~/.dotnet/sdk/XXXX` version folder or `~/dotnet/host/fxr/XXXX` version folder?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.