positron icon indicating copy to clipboard operation
positron copied to clipboard

No autocompletein for R and pyhtn in quarto files during Remote SSH

Open ChaoXu1997 opened this issue 8 months ago • 1 comments

System details:

Positron and OS details:

Positron Version: 2025.06.0 (system setup) build 48 Code - OSS Version: 1.99.0 Commit: 621d1ce8f7fecc9623e9ab59b36c62f23d626d3d Date: 2025-05-12T03:52:04.407Z Electron: 34.3.2 Chromium: 132.0.6834.210 Node.js: 20.18.3 V8: 13.2.152.41-electron.0 OS: Windows_NT x64 10.0.22631

Interpreter details:

R 4.5.0 Python 3.10.12

Describe the issue:

When using Positron to connect to a server via SSH and running R or Python code through QMD files, code completion (tab completion) does not work.

Steps to reproduce the issue:

  1. Open Positron and connect to a remote server via SSH.
  2. Open a Quarto (.qmd) document.
  3. Add an R or Python code chunk.
  4. Try to use tab completion inside the code chunk.

Expected or desired behavior:

Tab completion should work inside code chunks in Quarto documents, even when connected to a remote server via SSH. This would help improve the coding experience and productivity.

Were there any error messages in the UI, Output panel, or Developer Tools console?

No error messages were shown in the UI, Output panel, or Developer Tools console. The tab completion simply does not respond.

Image

ChaoXu1997 avatar May 18 '25 08:05 ChaoXu1997

Thank you for opening this issue. I'm having trouble reproducing the problem. Can you provide the output logs for remote SSH? They can be found in the Output view under Remote - SSH.

timtmok avatar May 21 '25 19:05 timtmok

Let us know if you are able to share logs outlining more details on your problem!

juliasilge avatar Jun 02 '25 16:06 juliasilge

Hi @juliasilge,

Could you please consider reopening this issue? I am experiencing the same problem as originally reported. Interestingly, a coworker of mine does not encounter this issue, suggesting it might be related to specific environment configurations. I am using a Conda environment within the SSH session, perhaps is the cause?

Here are the details for reproducing the issue:

System details:

Positron Version: 2025.06.0 (system setup) build 167 Code - OSS Version: 1.100.0 Commit: e7e5d5590adc6bf7b760f837051cd2f57ea9e3dc Date: 2025-05-29T21:27:54.586Z Electron: 34.5.1 Chromium: 132.0.6834.210 Node.js: 20.19.0 V8: 13.2.152.41-electron.0 OS: Windows_NT x64 10.0.26100

Interpreter details:

Python version: 3.12.9 R version: R 4.3.3 Environment: Conda (remote, via SSH)

Describe the issue:

Similar to the problem reported by @ChaoXu1997: when using Positron to connect to a remote server via SSH and running R or Python code within Quarto (.qmd) files, code completion (tab completion) does not work.

Steps to reproduce the issue:

The steps to reproduce are the same as previously described:

  1. Open Positron and connect to a remote server via SSH.
  2. Open a Quarto (.qmd) document.
  3. Add an R or Python code chunk.
  4. Attempt to use tab completion inside the code chunk (e.g., by typing a partial variable/function name and pressing Tab).

Expected or desired behavior:

Tab completion should function correctly inside code chunks in Quarto documents, even when connected to a remote server via SSH.

Were there any error messages in the UI, Output panel, or Developer Tools console?

Yes, I am providing my output logs for the Remote-SSH connection below (personal info is censored).

[Info  - 08:58:49.748] Resolving ssh remote authority 'ssh-remote+[SERVER_HOSTNAME]' (attempt #1)
[Error  - 08:58:49.773] Couldn't get identities from OpenSSH agent
Error: Failed to connect to agent
	at Socket.r (c:\Program Files\Positron\resources\app\extensions\open-remote-ssh\dist\extension.js:1:132086)
	at Socket.emit (node:events:524:28)
	at Socket.emit (node:domain:489:12)
	at emitErrorNT (node:internal/streams/destroy:169:8)
	at emitErrorCloseNT (node:internal/streams/destroy:128:3)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
[Trace  - 08:58:49.773] Identity keys:
C:\Users\[LOCAL_USERNAME]\.ssh\id_ed25519 ssh-ed25519 SHA256:BXNexQkQwrdBqAU9Q/2Wt6/WsqMA+nmuaFYb4rAgBo0=
[Info  - 08:58:49.834] Trying no-auth authentication
[Info  - 08:58:49.879] Trying publickey authentication: C:\Users\[LOCAL_USERNAME]\.ssh\id_ed25519 ssh-ed25519 SHA256:BXNexQkQwrdBqAU9Q/2Wt6/WsqMA+nmuaFYb4rAgBo0=
[Trace  - 08:58:50.55] Server install command:

# Server installation script

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

DISTRO_VERSION="2025.06.0-167"
DISTRO_COMMIT="e7e5d5590adc6bf7b760f837051cd2f57ea9e3dc"
DISTRO_QUALITY="undefined"
DISTRO_VSCODIUM_RELEASE=""

SERVER_APP_NAME="positron-server"
SERVER_INITIAL_EXTENSIONS=""
SERVER_LISTEN_FLAG="--port=0"
SERVER_DATA_DIR="$HOME/.positron-server"
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 "256b0c189df9a8ce32518cf9: 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 "256b0c189df9a8ce32518cf9: 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"
        ARCH_LONG="x86_64"
        ;;
    armv7l | armv8l)
        SERVER_ARCH="armhf"
        ARCH_LONG="armhf"
        ;;
    arm64 | aarch64)
        SERVER_ARCH="arm64"
        ARCH_LONG="arm64"
        ;;
    ppc64le)
        SERVER_ARCH="ppc64le"
        ARCH_LONG="ppc64le"
        ;;
    riscv64)
        SERVER_ARCH="riscv64"
        ARCH_LONG="riscv64"
        ;;
    *)
        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://cdn.posit.co/positron/dailies/reh/\${arch-long}/positron-reh-\${os}-\${arch}-\${version}.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/\${arch-long}/$ARCH_LONG/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="[REDACTED_CONNECTION_TOKEN]"
    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  - 08:58:50.625] Server install command stdout:
Server script already installed in /home/[REMOTE_USERNAME]/.positron-server/bin/e7e5d5590adc6bf7b760f837051cd2f57ea9e3dc/bin/positron-server
256b0c189df9a8ce32518cf9: start
exitCode==0==
listeningOn==36627==
connectionToken==[REDACTED_CONNECTION_TOKEN]==
logFile==/home/[REMOTE_USERNAME]/.positron-server/.e7e5d5590adc6bf7b760f837051cd2f57ea9e3dc.log==
osReleaseId==ubuntu==
arch==x86_64==
platform==linux==
tmpDir==/run/user/[REMOTE_UID]==
256b0c189df9a8ce32518cf9: end

[Trace  - 08:58:50.641] Creating forwarding server 59907(local) => 59906(socks) => 36627(remote)

JuanTejedor avatar Jun 10 '25 09:06 JuanTejedor

@JuanTejedor We don't officially support R installed via conda and are tracking such support in #4398. We did provide some extremely initial/experimental support for conda and R in https://github.com/posit-dev/positron/pull/6988, if you would like to look at the details there and try it out; do be aware of the limitations we outline.

juliasilge avatar Jun 10 '25 19:06 juliasilge