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

Installing with apt install dotnet-sdk-6.0 yields no executable file on Ubuntu 20.04 #12939

Closed
V0ldek opened this issue Jan 2, 2022 · 6 comments

Comments

@V0ldek
Copy link

V0ldek commented Jan 2, 2022

Installing .NET SDK on Ubuntu 20.04 with the commands listed in the Install .NET on Ubuntu docs:

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

produces no dotnet executable.

Command 'dotnet' not found, but can be installed with:

sudo snap install dotnet-sdk

Listing files from the package:

dpkg -L dotnet-sdk-6.0 | grep -P "dotnet$"

gives

/usr/share/dotnet

The /usr/share/dotnet directory contains no executable. I compared this result with my other Ubuntu installation where I installed dotnet ages ago, and there it is installed in /usr/share/dotnet but there exists a /usr/share/dotnet/dotnet executable. It's as if the current download via apt didn't include any executables.

What am I doing wrong? How to install dotnet on Ubuntu with APT?

Using snap is not an option.

@kasperk81
Copy link

cant repro

$ docker run -it ubuntu:20.04
$ apt update
$ apt-get install -y wget
$ wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
$ dpkg -i packages-microsoft-prod.deb
$ rm packages-microsoft-prod.deb
$ apt-get update && apt-get install -y apt-transport-https && apt-get update && apt-get install -y dotnet-sdk-6.0
$ dotnet --info

.NET SDK (reflecting any global.json):
 Version:   6.0.101
 Commit:    ef49f6213a

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.101/

Host (useful for support):
  Version: 6.0.1
  Commit:  3a25a7f1cc

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

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

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

@V0ldek
Copy link
Author

V0ldek commented Jan 5, 2022

I can indeed confirm that it works on a clean docker run. However, it fails just as I described on 4 different machines I own with Ubuntu 20.04, one of them being on WSL2.

Makes me think there must be something connecting them that breaks this install process, but I have no idea what it might be.

Here is the full output of my commands, this from my WSL2 instance, but they all look similar:

v0ldek@DESKTOP-BVC4E70:/mnt/c/Users/V0ldek$ ls /usr/share/dotnet
ls: cannot access '/usr/share/dotnet': No such file or directory
v0ldek@DESKTOP-BVC4E70:/mnt/c/Users/V0ldek$ cat /etc/issue
Ubuntu 20.04.3 LTS \n \l

v0ldek@DESKTOP-BVC4E70:/mnt/c/Users/V0ldek$ wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
--2022-01-06 00:11:12--  https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
Resolving packages.microsoft.com (packages.microsoft.com)... 13.80.99.124
Connecting to packages.microsoft.com (packages.microsoft.com)|13.80.99.124|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3124 (3.1K) [application/octet-stream]
Saving to: ‘packages-microsoft-prod.deb’

packages-microsoft-prod.deb   100%[=================================================>]   3.05K  --.-KB/s    in 0s

2022-01-06 00:11:12 (488 MB/s) - ‘packages-microsoft-prod.deb’ saved [3124/3124]

v0ldek@DESKTOP-BVC4E70:/mnt/c/Users/V0ldek$ sudo dpkg -i packages-microsoft-prod.deb
(Reading database ... 301697 files and directories currently installed.)
Preparing to unpack packages-microsoft-prod.deb ...
Unpacking packages-microsoft-prod (1.0-ubuntu20.04.1) over (1.0-ubuntu20.04.1) ...
Setting up packages-microsoft-prod (1.0-ubuntu20.04.1) ...
v0ldek@DESKTOP-BVC4E70:/mnt/c/Users/V0ldek$ rm packages-microsoft-prod.deb
v0ldek@DESKTOP-BVC4E70:/mnt/c/Users/V0ldek$ sudo apt-get update; \
 sudo ap>   sudo apt-get install -y apt-transport-https && \
>   sudo apt-get update && \
>   sudo apt-get install -y dotnet-sdk-6.0
Hit:1 https://packages.microsoft.com/ubuntu/20.04/prod focal InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:5 https://nvidia.github.io/libnvidia-container/ubuntu18.04/amd64  InRelease
Hit:6 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Get:7 https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04/amd64  InRelease [1481 B]
Get:8 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease [1474 B]
Fetched 2955 B in 1s (3701 B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
apt-transport-https is already the newest version (2.0.6).
0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 https://packages.microsoft.com/ubuntu/20.04/prod focal InRelease
Hit:5 https://nvidia.github.io/libnvidia-container/ubuntu18.04/amd64  InRelease
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease
Get:7 https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04/amd64  InRelease [1481 B]
Get:8 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease [1474 B]
Fetched 2955 B in 1s (4774 B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  aspnetcore-runtime-6.0 aspnetcore-targeting-pack-6.0 dotnet-apphost-pack-6.0 dotnet-hostfxr-6.0 dotnet-runtime-6.0
  dotnet-runtime-deps-6.0 dotnet-targeting-pack-6.0
The following NEW packages will be installed:
  aspnetcore-runtime-6.0 aspnetcore-targeting-pack-6.0 dotnet-apphost-pack-6.0 dotnet-hostfxr-6.0 dotnet-runtime-6.0
  dotnet-runtime-deps-6.0 dotnet-sdk-6.0 dotnet-targeting-pack-6.0
0 upgraded, 8 newly installed, 0 to remove and 12 not upgraded.
Need to get 0 B/115 MB of archives.
After this operation, 462 MB of additional disk space will be used.
Selecting previously unselected package dotnet-hostfxr-6.0.
(Reading database ... 301697 files and directories currently installed.)
Preparing to unpack .../0-dotnet-hostfxr-6.0_6.0.1-1_amd64.deb ...
Unpacking dotnet-hostfxr-6.0 (6.0.1-1) ...
Selecting previously unselected package dotnet-runtime-deps-6.0.
Preparing to unpack .../1-dotnet-runtime-deps-6.0_6.0.1-1_amd64.deb ...
Unpacking dotnet-runtime-deps-6.0 (6.0.1-1) ...
Selecting previously unselected package dotnet-runtime-6.0.
Preparing to unpack .../2-dotnet-runtime-6.0_6.0.1-1_amd64.deb ...
Unpacking dotnet-runtime-6.0 (6.0.1-1) ...
Selecting previously unselected package aspnetcore-runtime-6.0.
Preparing to unpack .../3-aspnetcore-runtime-6.0_6.0.1-1_amd64.deb ...
Unpacking aspnetcore-runtime-6.0 (6.0.1-1) ...
Selecting previously unselected package dotnet-targeting-pack-6.0.
Preparing to unpack .../4-dotnet-targeting-pack-6.0_6.0.1-1_amd64.deb ...
Unpacking dotnet-targeting-pack-6.0 (6.0.1-1) ...
Selecting previously unselected package aspnetcore-targeting-pack-6.0.
Preparing to unpack .../5-aspnetcore-targeting-pack-6.0_6.0.0-1_amd64.deb ...
Unpacking aspnetcore-targeting-pack-6.0 (6.0.0-1) ...
Selecting previously unselected package dotnet-apphost-pack-6.0.
Preparing to unpack .../6-dotnet-apphost-pack-6.0_6.0.1-1_amd64.deb ...
Unpacking dotnet-apphost-pack-6.0 (6.0.1-1) ...
Selecting previously unselected package dotnet-sdk-6.0.
Preparing to unpack .../7-dotnet-sdk-6.0_6.0.101-1_amd64.deb ...
Unpacking dotnet-sdk-6.0 (6.0.101-1) ...
Setting up dotnet-apphost-pack-6.0 (6.0.1-1) ...
Setting up dotnet-targeting-pack-6.0 (6.0.1-1) ...
Setting up dotnet-runtime-deps-6.0 (6.0.1-1) ...
Setting up aspnetcore-targeting-pack-6.0 (6.0.0-1) ...
Setting up dotnet-hostfxr-6.0 (6.0.1-1) ...
Setting up dotnet-runtime-6.0 (6.0.1-1) ...
Setting up aspnetcore-runtime-6.0 (6.0.1-1) ...
Setting up dotnet-sdk-6.0 (6.0.101-1) ...
This software may collect information about you and your use of the software, and send that to Microsoft.
Please visit http://aka.ms/dotnet-cli-eula for more information.
Welcome to .NET!
---------------------
Learn more about .NET: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

Configuring...
--------------
A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
v0ldek@DESKTOP-BVC4E70:/mnt/c/Users/V0ldek$ dotnet --info
dotnet: command not found
v0ldek@DESKTOP-BVC4E70:/mnt/c/Users/V0ldek$ ls /usr/share/dotnet
host  packs  sdk  sdk-manifests  shared  templates

@dagood
Copy link
Member

dagood commented Jan 10, 2022

The following NEW packages will be installed:
  aspnetcore-runtime-6.0 aspnetcore-targeting-pack-6.0 dotnet-apphost-pack-6.0 dotnet-hostfxr-6.0 dotnet-runtime-6.0
  dotnet-runtime-deps-6.0 dotnet-sdk-6.0 dotnet-targeting-pack-6.0

I noticed dotnet-host isn't present in this list, but it is present when .NET is installed on a fresh machine. Did any of your machines have an earlier version of .NET already installed, or installed at some point in the past?

Can you try running dpkg -l 'dotnet*' to see what you have installed at this point?

I'm able to reproduce your situation if I install dotnet-sdk-5.0, run rm -rf /usr/share/dotnet, then install dotnet-sdk-6.0. Removing folders isn't a proper way to uninstall programs that were installed via package manager, but this is the best repro I can think of. If something like this is what happened, you can repair your machine with sudo apt reinstall dotnet-host.

@V0ldek
Copy link
Author

V0ldek commented Jan 10, 2022

That's a good catch. dotnet-host is indeed installed in apt even though it doesn't exist in /usr/share/dotnet. I did not run rm -rf /usr/share/dotnet, so I'm guessing something corrupted my /usr/share at some point, causing this issue. It's kind of ridiculous that it happened on four different Ubuntus in exactly the same way, but I guess I always tried to keep them synchronised.

sudo apt reinstall dotnet-host and then sudo apt install dotnet-sdk-6.0 fixes the issue. Many thanks.

@V0ldek V0ldek closed this as completed Jan 10, 2022
@Moawyah-AbdulRahman
Copy link

it seems that I have a similar problem.
i tried what you've done, now dotnet is recognised, but when i try to do something with it (ex: --info, --help, --list-sdks ...etc) i get a massage that says "A fatal error occurred. The folder [/usr/lib/dotnet/dotnet6-6.0.108/host/fxr] does not exist".

note:
when i reinstalled dotnet-host i got a massage that says:
dpkg: warning: files list file for package 'dotnet-host' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'dotnet-apphost-pack-6.0' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'dotnet-targeting-pack-6.0' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'dotnet-hostfxr-6.0' missing; assuming package has no files currently installed
(Reading database ... 201066 files and directories currently installed.)
Preparing to unpack .../dotnet-host_6.0.108-0ubuntu122.04.1_amd64.deb ...
Unpacking dotnet-host (6.0.108-0ubuntu1
22.04.1) over (6.0.108-0ubuntu122.04.1) ...
Setting up dotnet-host (6.0.108-0ubuntu1
22.04.1) ...
update-alternatives: using /usr/lib/dotnet/dotnet6-6.0.108/dotnet to provide /usr/bin/dotnet (dotnet) in auto mode
update-alternatives: warning: skip creation of /usr/share/bash-completion/completions/dotnet because
associated file /usr/lib/dotnet/dotnet6-6.0.108/bash-completion/completions/dotnet (of link group d
otnet) doesn't exist

and when i installed dotnet-sdk-6.0 i got:
dpkg: warning: files list file for package 'dotnet-apphost-pack-6.0' missing; assuming package has n
o files currently installed
dpkg: warning: files list file for package 'dotnet-targeting-pack-6.0' missing; assuming package has
no files currently installed
dpkg: warning: files list file for package 'dotnet-hostfxr-6.0' missing; assuming package has no fil
es currently installed

@dagood
Copy link
Member

dagood commented Aug 15, 2022

@Moawyah-AbdulRahman, you've found an old, closed issue, which aren't typically monitored for new comments. You should take a look at this, instead, since it appears you're on Ubuntu 22.04:

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

No branches or pull requests

4 participants