microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
910 stars 130 forks source link

Support Alpine Linux #1902

Open frenck opened 4 years ago

frenck commented 4 years ago

Environment data

Expected behaviour

The language server to start.

Actual behaviour

The server crashes, without any error or warning message that could provide a useful hint to what is going on.

Logs

Downloading https://pvsc.azureedge.net/python-language-server-beta/Python-Language-Server-linux-x64.0.5.30.nupkg...
Language server download complete
Unpacking archive... done
[Error - 10:00:05 AM] Starting client failed
Launching server using command /root/.vscode-server/extensions/ms-python.python-2020.1.58038/languageServer.0.5.30/Microsoft.Python.LanguageServer failed.

I've set the logLevel to Trace, but it has no effect on the output. Would love some guidance on how to get more information out of it.

Code Snippet / Additional lnformation

The Python Language server states in the docs:

The language server can only run on platforms where the .NET Core can run.

Which is great, since Microsoft has a .NET Core for Alpine, however, adding that manually to the container, doesn't help either.

The used Dockerfile

FROM homeassistant/amd64-homeassistant-base:5.4

WORKDIR /usr/src

# Install build tools
RUN apk add --no-cache \
    build-base \
    coreutils \
    procps

# .NET Core dependencies
RUN apk add --no-cache \
    krb5-libs \
    libgcc \
    libintl \
    libssl1.1 \
    libstdc++ \
    zlib

ENV \
    DOTNET_RUNNING_IN_CONTAINER=true \
    DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true

# Install .NET Core
RUN dotnet_version=3.1.1 \
    && wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Runtime/$dotnet_version/dotnet-runtime-$dotnet_version-linux-musl-x64.tar.gz \
    && dotnet_sha512='73a29e7f6c662beabd70d20bb4331c7a4d3fe4096002cb802f2db08946fd918681151e1cfcda537210231883852364a5c7707e11bbc28d8613ff4ec1a8e98015' \
    && echo "$dotnet_sha512  dotnet.tar.gz" | sha512sum -c - \
    && mkdir -p /usr/share/dotnet \
    && tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
    && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
    && rm dotnet.tar.gz

WORKDIR /workspaces

# Install Python dependencies from requirements
COPY requirements_test.txt requirements_test_pre_commit.txt homeassistant/package_constraints.txt ./
RUN \
    pip3 install \
        --find-links "${WHEELS_LINKS}" \
        -r requirements_test.txt \
        -c package_constraints.txt \
    && rm -f \
        package_constraints.txt \
        requirements_test_pre_commit.txt \
        requirements_test.txt

# Set the default shell to bash instead of sh
ENV SHELL /bin/bash

Upstream PR, where we want to apply this: home-assistant/home-assistant#31721

Upstream PR is closed until a solution is found, and does not have dotnet core installed as I have done in the above-provided example, which suffers from the same issue.

MikhailArkhipov commented 4 years ago

Is it x86 or ARM? LS is not built for ARM.

frenck commented 4 years ago

This is all x86_64.

MikhailArkhipov commented 4 years ago

Try launching Microsoft.Python.LanguageServer manually from console. Perhaps chmod +x Microsoft.Python.LanguageServer will help?

jerrcs commented 4 years ago

Alpine Linux uses musl, not libc. I believe that's why it refuses to execute, since the language server executable is linked against libc.

jakebailey commented 4 years ago

https://github.com/microsoft/python-language-server/blob/master/CONTRIBUTING.md has some instructions for building from source and pointing the extension at the built code. I'm not certain the constraints about building for Alpine with dotnet, but it might be the case that you need to build with musl to get musl in the final output.

jakebailey commented 4 years ago

Though, I was under the impression that both the traditional libc and musl presented themselves as "libc" at load time, to be compatible, so I'm not convinced that's it either.

MikhailArkhipov commented 4 years ago

Ah, that clears it. For dotnet publish we specify <RuntimeIdentifiers>win-x86;win-x64;osx-x64;linux-x64</RuntimeIdentifiers> and linux-x64 does not include Alpine. According to RID catalog https://docs.microsoft.com/en-us/dotnet/core/rid-catalog it has to be linux-musl-x64

To make this work two things needs to happen

MikhailArkhipov commented 4 years ago

At the moment LS may have to be built from source and installed manually per https://github.com/microsoft/python-language-server/issues/1698