dotnet / cli-lab

A guided tool will be provided to enable the controlled clean up of a system such that only the desired versions of the Runtime and SDKs remain.
MIT License
625 stars 56 forks source link

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

Open tillig opened 1 year ago

tillig commented 1 year ago

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.

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.

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.

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

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?

HaseebAhmed49 commented 3 months ago

It works for me

andherson17 commented 1 month ago

A year later I'm seeing this issue on a Mac Mini M1, and found this thread. I'm not familiar with just about anything Apple, and less about entering commands in a terminal.

I installed dotnet-sdk-8.0.402-osx-x64.pkg from here: https://dotnet.microsoft.com/en-us/download/dotnet/8.0 as a requirement for another piece not software, and the dotnet command was not found in terminal. I've set paths in Windows, but have failed to figure out if that's the case in the macOS.

Hoping to uninstall and start over, I downloaded the uninstaller for it here: https://github.com/dotnet/cli-lab/releases

But after finally figuring out the right commands to set, I'm getting that admin privileges error: The current user does not have adequate privileges.

I'm not quite sure where else to find support for this. I am listed as an admin in Mac system settings. Has anyone seen a fix or workaround fore this since tillig's post last year?