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

Python extension does not work on the remote host #144

Closed
rickysixx opened this issue Mar 3, 2024 · 4 comments
Closed

Python extension does not work on the remote host #144

rickysixx opened this issue Mar 3, 2024 · 4 comments

Comments

@rickysixx
Copy link

I am trying to work on a Python project hosted on a remote machine I connect to using the Open Remote - SSH extension.

I have installed the ms-python/python extension on the remote server:
image

The installation seems to be successful, because in the command palette I find some commands related to that extension:
image

even though none of these commands works:

image

Anyway, the main problem is that I don't get any editor assistance when I edit a Python file on the remote host (no intellisense, no linting, etc.).

On my local environment, instead, the Python extension works without any issues.

This is the output of Help > About:

Version: 1.87.0
Commit: 019f4d1419fbc8219a181fab7892ebccf7ee29a2
Date: 2024-03-01T14:16:19.238Z
Electron: 27.3.4
ElectronBuildId: undefined
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Linux x64 6.7.6-arch1-2

I am running Arch Linux on my local environment, while the remote server runs Debian 12.

@jeanp413
Copy link
Owner

jeanp413 commented Mar 4, 2024

Looks like the extension failed to activate, can you share logs of the python extension and remote extension host

@rickysixx
Copy link
Author

rickysixx commented Mar 4, 2024

Hi @jeanp413, sure!

Here are the logs of Remote - SSH:

[Info  - 21:33:25.672] Resolving ssh remote authority 'ssh-remote+root@gamemaster' (attemp #1)
[Info  - 21:33:26.66] Trying password authentication
[Trace  - 21:33:29.111] Server install command:

# Server installation script

TMP_DIR="${XDG_RUNTIME_DIR:-"/tmp"}"

DISTRO_VERSION="1.87.0"
DISTRO_COMMIT="019f4d1419fbc8219a181fab7892ebccf7ee29a2"
DISTRO_QUALITY="stable"
DISTRO_VSCODIUM_RELEASE=""

SERVER_APP_NAME="code-server-oss"
SERVER_INITIAL_EXTENSIONS=""
SERVER_LISTEN_FLAG="--port=0"
SERVER_DATA_DIR="$HOME/.vscode-server-oss"
SERVER_DIR="$SERVER_DATA_DIR/bin/$DISTRO_COMMIT"
SERVER_SCRIPT="$SERVER_DIR/bin/$SERVER_APP_NAME"
SERVER_LOGFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.log"
SERVER_PIDFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.pid"
SERVER_TOKENFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.token"
SERVER_ARCH=
SERVER_CONNECTION_TOKEN=
SERVER_DOWNLOAD_URL=

LISTENING_ON=
OS_RELEASE_ID=
ARCH=
PLATFORM=

# Mimic output from logs of remote-ssh extension
print_install_results_and_exit() {
    echo "35556214c8016c02cf5c8b5f: start"
    echo "exitCode==$1=="
    echo "listeningOn==$LISTENING_ON=="
    echo "connectionToken==$SERVER_CONNECTION_TOKEN=="
    echo "logFile==$SERVER_LOGFILE=="
    echo "osReleaseId==$OS_RELEASE_ID=="
    echo "arch==$ARCH=="
    echo "platform==$PLATFORM=="
    echo "tmpDir==$TMP_DIR=="
    
    echo "35556214c8016c02cf5c8b5f: end"
    exit 0
}

# Check if platform is supported
KERNEL="$(uname -s)"
case $KERNEL in
    Darwin)
        PLATFORM="darwin"
        ;;
    Linux)
        PLATFORM="linux"
        ;;
    FreeBSD)
        PLATFORM="freebsd"
        ;;
    DragonFly)
        PLATFORM="dragonfly"
        ;;
    *)
        echo "Error platform not supported: $KERNEL"
        print_install_results_and_exit 1
        ;;
esac

# Check machine architecture
ARCH="$(uname -m)"
case $ARCH in
    x86_64 | amd64)
        SERVER_ARCH="x64"
        ;;
    armv7l | armv8l)
        SERVER_ARCH="armhf"
        ;;
    arm64 | aarch64)
        SERVER_ARCH="arm64"
        ;;
    ppc64le)
        SERVER_ARCH="ppc64le"
        ;;
    *)
        echo "Error architecture not supported: $ARCH"
        print_install_results_and_exit 1
        ;;
esac

# https://www.freedesktop.org/software/systemd/man/os-release.html
OS_RELEASE_ID="$(grep -i '^ID=' /etc/os-release 2>/dev/null | sed 's/^ID=//gi' | sed 's/"//g')"
if [[ -z $OS_RELEASE_ID ]]; then
    OS_RELEASE_ID="$(grep -i '^ID=' /usr/lib/os-release 2>/dev/null | sed 's/^ID=//gi' | sed 's/"//g')"
    if [[ -z $OS_RELEASE_ID ]]; then
        OS_RELEASE_ID="unknown"
    fi
fi

# Create installation folder
if [[ ! -d $SERVER_DIR ]]; then
    mkdir -p $SERVER_DIR
    if (( $? > 0 )); then
        echo "Error creating server install directory"
        print_install_results_and_exit 1
    fi
fi

SERVER_DOWNLOAD_URL="$(echo "https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v1.84.0/openvscode-server-v1.84.0-\${os}-\${arch}.tar.gz" | sed "s/\${quality}/$DISTRO_QUALITY/g" | sed "s/\${version}/$DISTRO_VERSION/g" | sed "s/\${commit}/$DISTRO_COMMIT/g" | sed "s/\${os}/$PLATFORM/g" | sed "s/\${arch}/$SERVER_ARCH/g" | sed "s/\${release}/$DISTRO_VSCODIUM_RELEASE/g")"

# Check if server script is already installed
if [[ ! -f $SERVER_SCRIPT ]]; then
    if [[ "$PLATFORM" != "darwin" ]] && [[ "$PLATFORM" != "linux" ]]; then
        echo "Error "$PLATFORM" needs manual installation of remote extension host"
        print_install_results_and_exit 1
    fi

    pushd $SERVER_DIR > /dev/null

    if [[ ! -z $(which wget) ]]; then
        wget --tries=3 --timeout=10 --continue --no-verbose -O vscode-server.tar.gz $SERVER_DOWNLOAD_URL
    elif [[ ! -z $(which curl) ]]; then
        curl --retry 3 --connect-timeout 10 --location --show-error --silent --output vscode-server.tar.gz $SERVER_DOWNLOAD_URL
    else
        echo "Error no tool to download server binary"
        print_install_results_and_exit 1
    fi

    if (( $? > 0 )); then
        echo "Error downloading server from $SERVER_DOWNLOAD_URL"
        print_install_results_and_exit 1
    fi

    tar -xf vscode-server.tar.gz --strip-components 1
    if (( $? > 0 )); then
        echo "Error while extracting server contents"
        print_install_results_and_exit 1
    fi

    if [[ ! -f $SERVER_SCRIPT ]]; then
        echo "Error server contents are corrupted"
        print_install_results_and_exit 1
    fi

    rm -f vscode-server.tar.gz

    popd > /dev/null
else
    echo "Server script already installed in $SERVER_SCRIPT"
fi

# Try to find if server is already running
if [[ -f $SERVER_PIDFILE ]]; then
    SERVER_PID="$(cat $SERVER_PIDFILE)"
    SERVER_RUNNING_PROCESS="$(ps -o pid,args -p $SERVER_PID | grep $SERVER_SCRIPT)"
else
    SERVER_RUNNING_PROCESS="$(ps -o pid,args -A | grep $SERVER_SCRIPT | grep -v grep)"
fi

if [[ -z $SERVER_RUNNING_PROCESS ]]; then
    if [[ -f $SERVER_LOGFILE ]]; then
        rm $SERVER_LOGFILE
    fi
    if [[ -f $SERVER_TOKENFILE ]]; then
        rm $SERVER_TOKENFILE
    fi

    touch $SERVER_TOKENFILE
    chmod 600 $SERVER_TOKENFILE
    SERVER_CONNECTION_TOKEN="7d1ed0b3-fe85-4c84-aff9-bc947358ee41"
    echo $SERVER_CONNECTION_TOKEN > $SERVER_TOKENFILE

    $SERVER_SCRIPT --start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --enable-remote-auto-shutdown --accept-server-license-terms &> $SERVER_LOGFILE &
    echo $! > $SERVER_PIDFILE
else
    echo "Server script is already running $SERVER_SCRIPT"
fi

if [[ -f $SERVER_TOKENFILE ]]; then
    SERVER_CONNECTION_TOKEN="$(cat $SERVER_TOKENFILE)"
else
    echo "Error server token file not found $SERVER_TOKENFILE"
    print_install_results_and_exit 1
fi

if [[ -f $SERVER_LOGFILE ]]; then
    for i in {1..5}; do
        LISTENING_ON="$(cat $SERVER_LOGFILE | grep -E 'Extension host agent listening on .+' | sed 's/Extension host agent listening on //')"
        if [[ -n $LISTENING_ON ]]; then
            break
        fi
        sleep 0.5
    done

    if [[ -z $LISTENING_ON ]]; then
        echo "Error server did not start sucessfully"
        print_install_results_and_exit 1
    fi
else
    echo "Error server log file not found $SERVER_LOGFILE"
    print_install_results_and_exit 1
fi

# Finish server setup
print_install_results_and_exit 0

[Trace  - 21:33:29.246] Server install command stdout:
Server script already installed in /root/.vscode-server-oss/bin/019f4d1419fbc8219a181fab7892ebccf7ee29a2/bin/code-server-oss
Server script is already running /root/.vscode-server-oss/bin/019f4d1419fbc8219a181fab7892ebccf7ee29a2/bin/code-server-oss
35556214c8016c02cf5c8b5f: start
exitCode==0==
listeningOn==37689==
connectionToken==c873a934-a0be-4d9d-ad26-c034edffa374==
logFile==/root/.vscode-server-oss/.019f4d1419fbc8219a181fab7892ebccf7ee29a2.log==
osReleaseId==debian==
arch==x86_64==
platform==linux==
tmpDir==/run/user/0==
35556214c8016c02cf5c8b5f: end

[Trace  - 21:33:29.249] Creating forwarding server 39689(local) => 40985(socks) => 37689(remote)

Side note: it's intentional that the Code OSS Server runs as the root user. This is a virtual machine I setup to test some code that needs to run as root.

I can't find any logs from the Python extension instead. I don't see it in the output list neither:
image

In the remote server I find the extension file ms-python.python-2024.2.1-universal in the ~/.openvscode-server/extensions directory:

root@gamemaster:~/.openvscode-server/extensions# ls -l
total 12
-rw-r--r--  1 root root 1227 Mar  3 16:08 extensions.json
drwxr-xr-x  4 root root 4096 Mar  3 14:58 ms-python.debugpy-2024.0.0-linux-x64
drwxr-xr-x 12 root root 4096 Mar  3 14:58 ms-python.python-2024.2.1-universal

but I don't know if this is enough to say that the Python extension was correctly installed/activated.

EDIT

Today I was able to get other logs.

These are Server logs after installing the Python extension:

2024-03-03 16:54:37.708 [info] 




2024-03-03 16:54:37.708 [info] Extension host agent started.
2024-03-03 16:54:37.708 [info] Started initializing default profile extensions in extensions installation folder. file:///root/.openvscode-server/extensions
2024-03-03 16:54:38.566 [info] Completed initializing default profile extensions in extensions installation folder. file:///root/.openvscode-server/extensions
2024-03-03 16:54:38.608 [info] [127.0.0.1][1fe0c59e][ManagementConnection] New connection established.
2024-03-03 16:54:38.681 [info] [127.0.0.1][8d8bb6cf][ExtensionHostConnection] New connection established.
2024-03-03 16:54:38.777 [info] [127.0.0.1][8d8bb6cf][ExtensionHostConnection] <22601> Launched Extension Host Process.
2024-03-03 16:54:55.597 [info] [127.0.0.1][1fe0c59e][ManagementConnection] The client has disconnected gracefully, so the connection will be disposed.
2024-03-03 16:54:55.619 [info] [127.0.0.1][8d8bb6cf][ExtensionHostConnection] <22601> Extension Host Process exited with code: 0, signal: null.
2024-03-03 16:54:55.619 [info] Cancelling previous shutdown timeout
2024-03-03 16:54:55.619 [info] Last EH closed, waiting before shutting down
2024-03-03 16:54:59.788 [info] [127.0.0.1][4d5d9e19][ManagementConnection] New connection established.
2024-03-03 16:54:59.788 [info] [127.0.0.1][6a95e34a][ExtensionHostConnection] New connection established.
2024-03-03 16:54:59.795 [info] [127.0.0.1][6a95e34a][ExtensionHostConnection] <22708> Launched Extension Host Process.
2024-03-03 16:55:19.433 [info] Getting Manifest... ms-python.python
2024-03-03 16:55:21.031 [info] Installing extension: ms-python.python
2024-03-03 16:55:22.013 [info] Getting Manifest... ms-python.debugpy
2024-03-03 16:55:22.725 [info] Installing extension: ms-python.debugpy ms-python.python
2024-03-03 16:55:26.219 [info] Extension signature verification is not done: ms-python.debugpy
2024-03-03 16:55:26.985 [info] Extracted extension to file:///root/.openvscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64: ms-python.debugpy
2024-03-03 16:55:27.035 [info] Renamed to /root/.openvscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64
2024-03-03 16:55:27.043 [info] Extracting extension completed. ms-python.debugpy
2024-03-03 16:55:32.328 [info] Extension signature verification is not done: ms-python.python
2024-03-03 16:55:34.854 [info] Extracted extension to file:///root/.openvscode-server/extensions/ms-python.python-2024.2.1-universal: ms-python.python
2024-03-03 16:55:35.088 [info] Renamed to /root/.openvscode-server/extensions/ms-python.python-2024.2.1-universal
2024-03-03 16:55:35.108 [info] Extracting extension completed. ms-python.python
2024-03-03 16:55:35.219 [info] Extension installed successfully: ms-python.debugpy
2024-03-03 16:55:35.219 [info] Extension installed successfully: ms-python.python
2024-03-03 16:59:55.622 [info] New EH opened, aborting shutdown

I noticed that in the Remote Tunnel Service logs there are some errors:

2024-03-05 12:10:30.754 [error] Missing 'tunnelApplicationConfig' or 'tunnelApplicationName' in product.json. Remote tunneling is not available.
2024-03-05 12:10:37.235 [error] Missing 'tunnelApplicationConfig' or 'tunnelApplicationName' in product.json. Remote tunneling is not available.
2024-03-05 12:12:15.963 [error] Missing 'tunnelApplicationConfig' or 'tunnelApplicationName' in product.json. Remote tunneling is not available.
2024-03-05 12:12:38.795 [error] Missing 'tunnelApplicationConfig' or 'tunnelApplicationName' in product.json. Remote tunneling is not available.

but I think this is not the problem here as the issue is expected (see here).

@jeanp413
Copy link
Owner

jeanp413 commented Mar 6, 2024

@rickysixx Looks like you are using code-oss and have overrided the server download url, your are using 1.87.0 locally but the remote server is 1.84.0, so just fix the download url and it should work.

@rickysixx
Copy link
Author

That fixed my problem, thanks @jeanp413!

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

2 participants