PowerShell: Powershell unable to find dotnet runtime when DOTNET_ROOT is set on Mariner
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
On Mariner, when DOTNET_ROOT is set, the dotnet runtime cannot be found. The same behavior works without issue when using Ubuntu.
echo $DOTNET_ROOT
dotnet --list-runtimes
pwsh -c "echo Hello"
mkdir -p /tmp/hostedtoolcache/dotnet
export DOTNET_ROOT=/tmp/hostedtoolcache/dotnet
dotnet --list-runtimes
pwsh -c "echo Hello"
Expected behavior
From Ubuntu
>
> Microsoft.AspNetCore.App 7.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
> Microsoft.NETCore.App 7.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
> Hello
> Microsoft.AspNetCore.App 7.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
> Microsoft.NETCore.App 7.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
> Hello
Actual behavior
From Mariner
>
> Microsoft.AspNetCore.App 6.0.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
> Microsoft.NETCore.App 6.0.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
> Microsoft.NETCore.App 7.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
> Hello
> Microsoft.AspNetCore.App 6.0.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
> Microsoft.NETCore.App 6.0.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
> Microsoft.NETCore.App 7.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
> You must install .NET to run this application.
>
> App: /opt/microsoft/powershell/7/pwsh
> Architecture: x64
> App host version: 7.0.3
> .NET location: Not found
>
> Learn about runtime installation:
> https://aka.ms/dotnet/app-launch-failed
>
> Download the .NET runtime:
> https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=mariner.2.0-x64&apphost_version=7.0.3
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.3.3
PSEdition Core
GitCommitId 7.3.3
OS Linux 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 29
I don’t know what is the directory hierarchy in your dotnet installation. If you have questions like this, then you are doing something wrong. And, executable files can be launched via a symlink… For example, as it is in powershell, which itself temporarily adds $PSHome to $env:PATH for the current session. To run the pwsh executable, you need to link it to a directory in $PATH or add $PSHome to it. Depending on the installation, the environment may differ.