dotnet/installer

The application '--version' does not exist

iainelder opened this issue ยท 13 comments

Today dotnet --version stopped working for me.

I use a Github Actions workflow to test my script to install dotnet-sdk-7.0 on Ubuntu 22.

My script copies the documented steps to Register the Microsoft package repository.

At the end I test the installation using dotnet --version.

Yesterday's CI run worked like this.

+ dotnet --version
7.0.302

Today's fails with the error in the title.

+ dotnet --version
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application '--version' does not exist.
  * You intended to execute a .NET SDK command:
      No .NET SDKs were found.

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

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found

Now how do I check the version?

Having the same issue. Any ideas?

The Troubleshooting section offers a lead.

Starting with Ubuntu 22.04 you may run into a situation where it seems only a piece of .NET is available. For example, when you've installed the runtime and the SDK, but when running dotnet --info only the runtime is listed. This can be related to using two different package sources. The built-in Ubuntu 22.04 and Ubuntu 22.10 package feeds include some versions of .NET, but not all, and you may have also installed .NET from the Microsoft feeds. For more information about how to fix this problem, see Troubleshoot .NET errors related to missing files on Linux.

See the section I need a version of .NET that isn't provided by my Linux distribution. The advice there worked for me.

I set the following content in /etc/apt/preferences.d/dotnet.pref:

Package: dotnet* aspnet* netstandard*
Pin: origin "archive.ubuntu.com"
Pin-Priority: -10

Today's CI run shows that the --version option is working again.

For me it's fixed, so I'll close this.

Does it solve your problem, @michelefa1988 ?

fyi
I still see this error if overwrite the entrypoint of mcr.microsoft.com/dotnet/runtime:7.0-alpine for Gitlab CI script entry

https://gitlab.com/giuliohome/fsharp/-/jobs/4364687217#L40

not a problem for me however, I've already sorted it out.

the best solution for this problem and others that Ubuntu has with versions is to use ASDF which has support for dotnet among others.

The command could not be loaded, possibly because:

  • You intended to execute a .NET application:
    The application '--version' does not exist.
  • You intended to execute a .NET SDK command:
    No .NET SDKs were found.

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

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found

how to fix this error in windows, when I want to show dotnet --version

The command could not be loaded, possibly because:

  • You intended to execute a .NET application:
    The application '--version' does not exist.
  • You intended to execute a .NET SDK command:
    No .NET SDKs were found.

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

Learn about SDK resolution: https://aka.ms/dotnet/sdk-not-found

how to fix this error in windows, when I want to show dotnet --version

I had the same issue.
"Most likely you've installed both the x86 (32-bit) and x64 (64-bit) versions of the .NET SDK. This is causing a conflict because when you run the dotnet command it's resolving to the x86 version when it should resolve to the x64 version. This is usually fixed by adjusting the %PATH% variable to resolve the x64 version first."
Here is the solution:

https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=net80#it-was-not-possible-to-find-any-installed-net-core-sdks

Good luck.

windows is so mid

It started happening again on Ubuntu 22.

On 2024-04-02 I had my last successful CI run.

+ dotnet --version
7.0.407

Since 2024-04-03 my CI runs fail like this:

+ dotnet --version
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application '--version' does not exist.
  * You intended to execute a .NET SDK command:
      No .NET SDKs were found.

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

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
Error: Process completed with exit code 145.

uhm ๐Ÿค”

https://launchpad.net/ubuntu/+source/dotnet7/7.0.117-0ubuntu1~23.10.2

image


Get:10 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 dotnet-host-7.0 amd64 7.0.117-0ubuntu1~22.04.1 [179 kB]

Get:11 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 dotnet-hostfxr-7.0 amd64 7.0.117-0ubuntu1~22.04.1 [164 kB]

Get:12 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 dotnet-runtime-7.0 amd64 7.0.117-0ubuntu1~22.04.1 [24.5 MB]

Get:13 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 dotnet-targeting-pack-7.0 amd64 7.0.117-0ubuntu1~22.04.1 [2751 kB]

Get:14 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 aspnetcore-runtime-7.0 amd64 


Around 2024-04-03 Canonical started distributing packages for dotnet to Ubuntu 22 from security.ubuntu.com.

Now I set the following content in /etc/apt/preferences.d/dotnet.pref:

Package: dotnet* aspnet* netstandard*
Pin: origin "archive.ubuntu.com"
Pin-Priority: -10

Package: dotnet* aspnet* netstandard*
Pin: origin "security.ubuntu.com"
Pin-Priority: -10

It pins packages for Microsoft products from repositories archive.ubuntu.com and security.ubuntu.com at a negative priority.

The negative priority prevents apt from using those repositories to install dotnet.

The latest CI run succeeds.

+ dotnet --version
7.0.407

Debugging notes

On Ubuntu 22 my installation script changes the apt preferences to avoid mixing packages from Microsoft's and Canonical's repositories.

It writes the following preferences fragment:

Package: dotnet* aspnet* netstandard*
Pin: origin "archive.ubuntu.com"
Pin-Priority: -10

After the script completes I run the policy command to show which runtime apt selected on Ubuntu 22.

The *** and the 100 in the output indicate that apt selected patch version 117-0ubuntu1~22.04.1 from repository security.ubuntu.com.

$ apt-cache policy dotnet-runtime-7.0
dotnet-runtime-7.0:
  Installed: 7.0.117-0ubuntu1~22.04.1
  Candidate: 7.0.117-0ubuntu1~22.04.1
  Version table:
     7.0.117-0ubuntu1~22.04.2 -10
        500 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages
 *** 7.0.117-0ubuntu1~22.04.1 500
        500 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages
        100 /var/lib/dpkg/status
     7.0.17-1 500
        500 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 Packages
...
     7.0.0-1 500
        500 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 Packages

From the "apt_preferences" manual page:

  • "If the target release has not been specified then APT simply assigns priority 100 to all installed package versions and priority 500 to all uninstalled package versions[.]"

  • "If two or more versions have the same priority, install the most recent one (that is, the one with the higher version number)."

apt assigns priority 500 to the packages from security.ubuntu.com and from packages.microsoft.com.

Canonical's patch version has a higher version number (117 > 17) so apt selects Canonical's package.

Thanks @giuliohome for the info.

Launchpad's publishing history explains why the behavior changed on 2024-04-03. Someone published a new package the day before.

Publishing history of dotnet7 7.0.117-0ubuntu1~23.10.2 source package in Ubuntu

  • Date: 2024-04-02 08:00:54 UTC
  • Status: Published
  • Target: Mantic
  • Pocket: updates
  • Component: universe
  • Section: devel
  • Version: 7.0.117-0ubuntu1~23.10.2
  • Created on: 2024-04-02
  • Created by: ลukasz Zemczak

I submited a PR to update the dotnet troubleshooting documentation.