dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
20.95k stars 4.9k forks source link

The SDK 'Microsoft.NET.Sdk.Web' specified cannot be found as a normal user but is found as root #8146

Closed leyan closed 1 year ago

leyan commented 1 year ago

Problem encountered on https://dotnet.microsoft.com/en-us/learn/aspnet/blazor-tutorial/create Operating System: linux

I am using Archlinux, and I am trying to follow the basic Blazor tutorial. However running dotnet new blazorserver -o BlazorApp --no-https -f net7.0 fails with the following error message:

The template "Blazor Server App" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/7.0-third-party-notices for details.

Processing post-creation actions...
Restoring /home/koxinga/programming/dotnet/BlazorApp/BlazorApp.csproj:
/home/koxinga/programming/dotnet/BlazorApp/BlazorApp.csproj : warning : The NuGetSdkResolver did not resolve this SDK because there was no version specified in the project or global.json.
/home/koxinga/programming/dotnet/BlazorApp/BlazorApp.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
Restore failed.
Post action failed.
Manual instructions: Run 'dotnet restore'

dotnet restore does not help, it fails with the same error message

However, the same command run as root succeeds and I can continue with the tutorial.

in both cases (normal user and root), the dotnet --list-sdks command gives the same result: 7.0.101 [/usr/share/dotnet/sdk] and there is indeed a /usr/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk.Web folder which is readable by the normal user, so I don't understand what could be the issue here.

Any idea of what could be happening?

omajid commented 1 year ago

I tried to reproduce this, but I couldn't. I ran into a very different error, though.

Here's the dockerfile I used:

FROM archlinux

RUN pacman -Sy --noconfirm dotnet-sdk-7.0

RUN useradd -mG wheel omajid && (printf 'omajid:omajid' | chpasswd)

USER omajid

CMD dotnet --info

Then I built it and ran it like this:

$ podman build -t arch -f archlinux-dotnet7.dockerfile
$ podman run -it arch /bin/bash
[omajid@bddf3adb4e8b /]$ cd
[omajid@bddf3adb4e8b ~]$ dotnet --info
.NET SDK:
 Version:   7.0.102
 Commit:    4bbdd14480

Runtime Environment:
 OS Name:     arch
 OS Version:  TEMPLATE_VERSION_ID
 OS Platform: Linux
 RID:         arch-x64
 Base Path:   /usr/share/dotnet/sdk/7.0.102/

Host:
  Version:      7.0.2
  Architecture: x64
  Commit:       d037e070eb

.NET SDKs installed:
  7.0.102 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

[omajid@bddf3adb4e8b ~]$ dotnet new blazorserver -o BlazorApp --no-https -f net7.0                                    

Welcome to .NET 7.0!                                                                                                  
---------------------      
SDK Version: 7.0.102         

----------------                                                                                                      
Installed an ASP.NET Core HTTPS development certificate.   
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).                               
Learn about HTTPS: https://aka.ms/dotnet-https             
----------------                                                                                                      
Write your first app: https://aka.ms/dotnet-hello-world                                                               
Find out what's new: https://aka.ms/dotnet-whats-new                                                                  
Explore documentation: https://aka.ms/dotnet-docs                                                                     
Report issues and find source on GitHub: https://github.com/dotnet/core                                               
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli                 
--------------------------------------------------------------------------------------                                
The template "Blazor Server App" was created successfully. 
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/7.0-third-party-notices for details.                                                                                                   

Processing post-creation actions...                                                                                   
Restoring /home/omajid/BlazorApp/BlazorApp.csproj:                                                                    
  Determining projects to restore...                                                                                  
  Restored /home/omajid/BlazorApp/BlazorApp.csproj (in 4.76 sec).                           
Restore succeeded.                                         

[omajid@bddf3adb4e8b ~]$ ls                                                                                           
BlazorApp                  
[omajid@bddf3adb4e8b ~]$ cd BlazorApp/                     
[omajid@bddf3adb4e8b BlazorApp]$ dotnet run                
Building...                                                                                                           
You must install or update .NET to run this application.   

App: /home/omajid/BlazorApp/bin/Debug/net7.0/BlazorApp     
Architecture: x64                                                                                                     
Framework: 'Microsoft.AspNetCore.App', version '7.0.0' (x64)                                                          
.NET location: /usr/share/dotnet                    

No frameworks were found.                                                                                             

Learn about framework resolution:                                                                                     
https://aka.ms/dotnet/app-launch-failed                    

To install missing framework, download:                    
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=7.0.0&arch=x64&rid=arch.TEMPLATE_VERSION_ID-x64                                        

How are you installing .NET? Are you using the distro packages? If so, can you try with the latest packages from ArchLinux?

omajid commented 1 year ago

cc @alucryd

alucryd commented 1 year ago

@omajid You need to install aspnet-runtime as well.

carlossanlop commented 1 year ago

@wli3 @dsplaisted any idea what could be happening here?

dsplaisted commented 1 year ago

It sounds like some of the files in the dotnet installation directory may have been created by root and can't be read by normal users. Probably this would be some part of dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk.Web.

carlossanlop commented 1 year ago

It sounds like some of the files in the dotnet installation directory may have been created by root and can't be read by normal users. Probably this would be some part of dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk.Web.

@leyan can you please confirm this is the case?

leyan commented 1 year ago

I tried with a new user without any specific permission and it works. It is only my main user that cannot do anything.

I also saw from @omajid message that the version 7.102 was available, but after upgrading the situation worsened, now "dotnet --version" answers 7.0.102 but that's the only command that works, even "dotnet --help" stays stuck without any feedback (for my main user).

Well, I probably have a setting set somewhere that causes issues, but I don't know how to analyze further. I tried removing local parameters for my account, but did not manage to find the root cause. As I can work around it, we can probably close this ticket, except if you have some more tips on how to get useful information.

github-actions[bot] commented 1 year ago

This issue is stale because there has been no response to a request for more information for 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because there was no response to a request for more information for 10 days.