Open lutzroeder opened 3 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
This will be fixed by @joeloff's work. Once we have a admin installer it will be used automatically and elevate when needed. Closing as we don't need to track this separately from the admin installer.
My engine is for MSIs, not for non-Windows systems. I don't think we scoped automatic elevation for any other OS platform for .NET 6. See dotnet/sdk#14956.
For mac/linux, I'm not sure that there's a way to detect from MSBuild (where this error is being thrown) that we would need to elevate in order to install the workload. @dsplaisted do you know if that's possible/ necessary?
How do we detect that we need to generate the "Inadequate permissions to access" message? We might be able to do the same thing in the MSBuild task that generates the workload installation instructions.
On Linux, does .NET wrap any calls into the stat/fstat APIs? That should allow you to query things like directories and get existing permissions. There's probably some extra work required, for example, a directory could be accessible to users within a group and the user doesn't have permissions, which doesn't imply elevation is required.
How do we detect that we need to generate the "Inadequate permissions to access" message?
We check if we can write to the resolved dotnet root: https://github.com/dotnet/sdk/blob/main/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallerFactory.cs#L75
.NET does implement the system calls, e.g. https://github.com/dotnet/coreclr/blob/master/src/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Stat.cs
If you get EACCESS as a result of trying to write a file or create a directory then that would be a clear indication that there is a permission issue.
Per workloads discussion, we're not going to prioritize this for .NET 6 as we'd have to tell we were on MacOS and figure out how to elevate which could be problematic. We considered during an improved error message telling them to elevate up front but that is backlog for net 6 rather than committed (so if we have time).
Please make sure that --print-download-link-only
args don't require elevation.
Please make sure that --print-download-link-only args don't require elevation.
Good catch, I'll put out a fix for this and track the issue here: https://github.com/dotnet/sdk/issues/18738
Thanks @sfoslund!
any solution to this issue?
We discussed in triage and are not aware of a way of elevating outside of windows which we already do. For non-windows, I'm not sure what we could do other than warn you that the command may require elevation during the original error.
There is also this discrepancy where you keep getting the following message even if you sudo dotnet workload update
:
Updates are avaliable for the following workload(s): maui-maccatalyst maui-ios maui-android. Run dotnet workload update
to get the latest.
The message doesn't show for sudo dotnet workload list
but does show for dotnet workload list
After the most recent MacOS/VS update, I cannot update or install workloads. The same message shows up even though I am running it with elevated (admin) permission:
I also notice that dotnet
command keeps printing the telemetry note (usually it only does once).
What about installing the workloads into a directory which does not require elevation?
This could also be beneficial for build servers where you can setup the needed workloads as step prior to dotnet build
.
Same issue with Dotnet workload install command. trying to update to .net8.0
Update: below command worked:
sudo dotnet workload install maui
Any update on this outside Windows?
Any update on this? It would be interesting to know if there is a suggested way to do it
try with sudo for mac and run as administrator for windows will works
@Ashishkumar5699 Thanks, this fixes the issue for me
Same issue with Dotnet workload install command. trying to update to .net8.0
Update: below command worked:
sudo dotnet workload install maui
this sudo dotnet workload install maui worked for me.
After trying several times to sudo or su first before running this command. Putting the sudo and the dotnet command in the same line worked. Just to mention this error occurred when trying to run dotnet maui project the 1st time on vscode for mac with c# dev kit.
sudo for mac
The error message for requiring a workload install shows a command line that will result in another error on macOS: