dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.68k stars 1.06k forks source link

Can't install .net on Docker / debian image in Mac M1 (Couldn't find any package by glob 'dotnet-sdk-6.0') #38090

Open MaurGi opened 9 months ago

MaurGi commented 9 months ago

Describe the bug

Getting Unable to locate package dotnet-sdk-6.0 when installing any dotnet component in a debian container on Mac M1 silicon - Works on PC.

To Reproduce

Dockerfile:

# Use an official Python runtime as a parent image
FROM python:3.12-slim-bookworm

# Install ZSH, Oh My ZSH
RUN apt-get update \
 && apt-get install -y zsh curl git \
 && apt-get install -y wget \
 && apt-get install -y lsb-release \
 && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# Install .net sdk version 6 for the speech tools
RUN wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
  && dpkg -i packages-microsoft-prod.deb \
  && rm packages-microsoft-prod.deb
RUN apt-get update \
  && apt-get upgrade -y \
  && apt-get install -y dotnet-sdk-6.0 \
  && apt-get install -y azure-cli

run:

$ docker build .
[+] Building 2.6s (7/7) FINISHED                                                                                           docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                       0.0s
 => => transferring dockerfile: 1.34kB                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                          0.0s
 => => transferring context: 2B                                                                                                            0.0s
 => [internal] load metadata for docker.io/library/python:3.12-slim-bookworm                                                               0.7s
 => [1/4] FROM docker.io/library/python:3.12-slim-bookworm@sha256:ee9a59cfdad294560241c9a8c8e40034f165feb4af7088c1479c2cdd84aafbed         0.0s
 => CACHED [2/4] RUN apt-get update  && apt-get install -y zsh curl git  && apt-get install -y wget  && apt-get install -y lsb-release  &  0.0s
 => CACHED [3/4] RUN wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb   &&  0.0s
 => ERROR [4/4] RUN apt-get update   && apt-get upgrade -y   && apt-get install -y dotnet-sdk-6.0   && apt-get install -y azure-cli        1.8s
------                                                                                                                                          
 > [4/4] RUN apt-get update   && apt-get upgrade -y   && apt-get install -y dotnet-sdk-6.0   && apt-get install -y azure-cli:                   
0.199 Hit:1 http://deb.debian.org/debian bookworm InRelease                                                                                     
0.200 Hit:2 http://deb.debian.org/debian bookworm-updates InRelease                                                                             
0.207 Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease                                                                   
0.335 Get:4 https://packages.microsoft.com/debian/12/prod bookworm InRelease [3617 B]                                                           
0.382 Get:5 https://packages.microsoft.com/debian/12/prod bookworm/main all Packages [342 B]
0.415 Get:6 https://packages.microsoft.com/debian/12/prod bookworm/main armhf Packages [4304 B]
0.441 Get:7 https://packages.microsoft.com/debian/12/prod bookworm/main amd64 Packages [24.0 kB]
0.441 Get:8 https://packages.microsoft.com/debian/12/prod bookworm/main arm64 Packages [4865 B]
0.447 Fetched 37.1 kB in 0s (123 kB/s)
0.447 Reading package lists...
0.816 Reading package lists...
1.133 Building dependency tree...
1.221 Reading state information...
1.244 Calculating upgrade...
1.354 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1.357 Reading package lists...
1.691 Building dependency tree...
1.772 Reading state information...
1.823 E: Unable to locate package dotnet-sdk-6.0
1.823 E: Couldn't find any package by glob 'dotnet-sdk-6.0'
1.823 E: Couldn't find any package by regex 'dotnet-sdk-6.0'
------
Dockerfile:15
--------------------
  14 |       && rm packages-microsoft-prod.deb
  15 | >>> RUN apt-get update \
  16 | >>>   && apt-get upgrade -y \
  17 | >>>   && apt-get install -y dotnet-sdk-6.0 \
  18 | >>>   && apt-get install -y azure-cli
  19 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update   && apt-get upgrade -y   && apt-get install -y dotnet-sdk-6.0   && apt-get install -y azure-cli" did not complete successfully: exit code: 100

Is the mac M1 supported?

Exceptions (if any)

Further technical details

dotnet-issue-labeler[bot] commented 9 months ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

lbussell commented 8 months ago

Hello, yes, M1 (and ARM processors in general) are supported. You are looking in the Debian package repos for .NET, but Debian does not produce their own distribution of .NET.

You probably want to use mcr.microsoft.com/dotnet/sdk:6.0-bookworm-slim image as your base image, and install python on that image. It is a multi-platform image with support for AMD64, ARM32, and ARM64.

Ubuntu provides their own distribution of .NET, but looks like it might be AMD64 only at the moment - https://packages.ubuntu.com/search?suite=jammy&arch=any&searchon=names&keywords=dotnet-sdk-6.0

richlander commented 8 months ago

FYI: Both Arm64 and Amd64 are available in jammy-updates.

https://packages.ubuntu.com/search?suite=jammy-updates&searchon=names&keywords=dotnet6

MaurGi commented 8 months ago

Hello, yes, M1 (and ARM processors in general) are supported. You are looking in the Debian package repos for .NET, but Debian does not produce their own distribution of .NET.

You probably want to use mcr.microsoft.com/dotnet/sdk:6.0-bookworm-slim image as your base image, and install python on that image. It is a multi-platform image with support for AMD64, ARM32, and ARM64.

Ubuntu provides their own distribution of .NET, but looks like it might be AMD64 only at the moment - https://packages.ubuntu.com/search?suite=jammy&arch=any&searchon=names&keywords=dotnet-sdk-6.0

Hi - thanks for your reply! I am explicitly adding the bookworm dep repo from Microsoft here:

RUN wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
  && dpkg -i packages-microsoft-prod.deb \
  && rm packages-microsoft-prod.deb

so it should be found there, am I correct?

MaurGi commented 8 months ago

FYI: Both Arm64 and Amd64 are available in jammy-updates.

https://packages.ubuntu.com/search?suite=jammy-updates&searchon=names&keywords=dotnet6

thanks - I am trying to use Debian though, do you suggest I switch to Ubuntu?

Consider that the same dockerfile works great when build on a Windows box...

richlander commented 8 months ago

Sorry for the confusion.

Yes, you can install .NET from packages.microsoft.com for Debian, directly from Ubuntu, or you can start with .NET images instead of Python ones. Those are all fine choices.

lbussell commented 8 months ago

Sorry for the confusion.

Yes, you can install .NET from packages.microsoft.com for Debian, directly from Ubuntu, or you can start with .NET images instead of Python ones. Those are all fine choices.

I don't see any arm64 .NET packages available from packages.microsoft.com. /cc @leecow who owns this area.

I think the easiest solution would be to use the mcr.microsoft.com/dotnet/sdk:6.0-bookworm-slim image as a base since it is multi-platform and contains ARM binaries for .NET.

MaurGi commented 8 months ago

That is a viable workaround, thx. I am not blocked, though @lbussell since I mainly work off of VSCode Remote from a Windows PC, that is not showing this problem, and I'd rather not change the base image since there is a lot that happens after that initial setup - I wonder how many other customers are having problems installing other MSFT packages on Debian12/Mac/ARM64.

leecow commented 8 months ago

We currently do not build ARM64 .DEB installers, which is why they are not available on packages.microsoft.com. Discussions are ongoing but I can't guess at the decisions or timelines. It would make sense to make the architecture situation clear in our Linux install documentation.

richlander commented 8 months ago

Oops. You are right Lee.

MaurGi commented 8 months ago

We currently do not build ARM64 .DEB installers, which is why they are not available on packages.microsoft.com. Discussions are ongoing but I can't guess at the decisions or timelines. It would make sense to make the architecture situation clear in our Linux install documentation.

yep that's where I got the info from - so what are my options? use a base Debian image with dotnet pre-installed?

richlander commented 8 months ago

The other option is install.sh.

MaurGi commented 8 months ago

got it - testing with install.sh with the instructions here: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install

thx

MaurGi commented 8 months ago

Note that just using the dotnet-install.sh as per above does not set the PATH or creates a lint in the /usr/bin folder - this worked though:

# Use an official Python runtime as a parent image
FROM python:3.12-slim-bookworm

# Scripted install for dotnet
# replaces apt-get install -y dotnet-sdk-6.0
# From https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \
 && chmod +x ./dotnet-install.sh \
 && ./dotnet-install.sh --channel 6.0 --version latest \
 && rm ./dotnet-install.sh
ENV DOTNET_ROOT="/root/.dotnet"
ENV PATH="$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools"

# Install sppech tools
RUN dotnet tool install --global Microsoft.CognitiveServices.Speech.CLI
richlander commented 8 months ago

Yup. That should work fine.

Here's another pattern:

https://github.com/dotnet/dotnet-docker/blob/7bca20cb06e1f912fc2e7fa8ce04dda606277537/src/runtime/8.0/jammy/amd64/Dockerfile#L22-L24

Forgind commented 8 months ago

@leecow,

Is this something you want to take a look at?

leecow commented 8 months ago

@Forgind - not sure what you're asking about? Richard's suggestion was a way in which Deb-based ARM64 users can acquire .NET.

Forgind commented 8 months ago

I'm not an expert, but it sounded like they might get the SDK, but we don't have arch-specific packages for them. @baronfel suggested that was an issue you were looking into?

richlander commented 8 months ago

This feels like a point in time problem with an acceptable workaround. Fair?

At the moment, we're not planning on producing Arm64 Linux packages. We'd much rather see .NET supported in official distro archives. The availability of x64 packages in both Ubuntu and packages.microsoft.com feeds almost does more harm than good. We would prefer not to repeat that with Arm64.