sdk icon indicating copy to clipboard operation
sdk copied to clipboard

`dotnet tool install` ignores $DOTNET_ROOT and defaults to $HOME/.dotnet

Open d3jv opened this issue 11 months ago • 5 comments

Describe the bug

Despite setting the $DOTNET_ROOT environment variable to a different location, dotnet tool install --global always installs tools to ~/.dotnet/tools and then prints out a message that I should at it to the PATH.

To Reproduce

Further technical details

dotnet --info clearly shows that everything is installed in /opt/dotnet

.NET SDK:
 Version:           8.0.201
 Commit:            4c2d78f037
 Workload version:  8.0.200-manifests.3097af8b

Runtime Environment:
 OS Name:     void
 OS Version:  
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /opt/dotnet/sdk/8.0.201/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.2
  Architecture: x64
  Commit:       1381d5ebd2

.NET SDKs installed:
  8.0.201 [/opt/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.2 [/opt/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.2 [/opt/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/opt/dotnet]

global.json file:
  Not found

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

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

d3jv avatar Feb 26 '24 18:02 d3jv

DOTNET_ROOT is not used by tools in any way by design - it only applies to the .NET AppHost (dotnet binary) and the .NET Runtime.

If you want to install tools to a custom location, you should use the --tool-path option of dotnet tool install to do so.

baronfel avatar Feb 26 '24 18:02 baronfel

If so, has it always been that way? The guide for installing dotnet on linux says to add $DOTNET_ROOT/tools to the PATH, implying that the tools should be installed there.

d3jv avatar Feb 26 '24 18:02 d3jv

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#net-sdk-and-cli-environment-variables says DOTNET_ROOT "Specifies the location of the .NET runtimes, if they are not installed in the default location." Why should global tools be installed to the directory of the runtimes?

KalleOlaviNiemitalo avatar Feb 26 '24 18:02 KalleOlaviNiemitalo

If so, has it always been that way? The guide for installing dotnet on linux says to as $DOTNET_ROOT/tools to the PATH, implying that the tools should be installed there.

Good spot - the guidance on that page is just wrong in that case. I'll work with the team to get it corrected.

baronfel avatar Feb 26 '24 18:02 baronfel

Thanks for reporting.

JL03-Yue avatar Feb 28 '24 07:02 JL03-Yue

@d3jv Thank you for reporting. Are there any other problems?

JL03-Yue avatar Mar 21 '24 21:03 JL03-Yue

@JL03-Yue Haven't noticed anything else yet.

d3jv avatar Mar 22 '24 09:03 d3jv