Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The application '--version' does not exist #16438

Closed
iainelder opened this issue May 19, 2023 · 13 comments · Fixed by dotnet/docs#40352
Closed

The application '--version' does not exist #16438

iainelder opened this issue May 19, 2023 · 13 comments · Fixed by dotnet/docs#40352

Comments

@iainelder
Copy link

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?

@michelefa1988
Copy link

Having the same issue. Any ideas?

@iainelder
Copy link
Author

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.

@iainelder
Copy link
Author

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 ?

@giuliohome
Copy link

giuliohome commented May 28, 2023

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.

@TalesPalma
Copy link

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

@SajanaFathima
Copy link

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

@jamerson429
Copy link

jamerson429 commented Nov 23, 2023

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.

@wayjake
Copy link

wayjake commented Jan 15, 2024

windows is so mid

@iainelder
Copy link
Author

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.

@iainelder iainelder reopened this Apr 6, 2024
@giuliohome
Copy link

giuliohome commented Apr 6, 2024

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 


iainelder added a commit to iainelder/dotnet-docs that referenced this issue Apr 6, 2024
Around 2024-04-03 Canonical started distributing packages for dotnet to Ubuntu 22 from `security.ubuntu.com`.

See dotnet/installer#16438.
iainelder added a commit to iainelder/dotfiles that referenced this issue Apr 6, 2024
@iainelder
Copy link
Author

iainelder commented Apr 6, 2024

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.

@iainelder
Copy link
Author

iainelder commented Apr 6, 2024

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

@iainelder
Copy link
Author

I submited a PR to update the dotnet troubleshooting documentation.

adegeo pushed a commit to dotnet/docs that referenced this issue May 2, 2024
Around 2024-04-03 Canonical started distributing packages for dotnet to Ubuntu 22 from `security.ubuntu.com`.

See dotnet/installer#16438.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants