open-remote-ssh icon indicating copy to clipboard operation
open-remote-ssh copied to clipboard

Does not work if remote host default shell is csh

Open fin-tsg opened this issue 1 year ago • 1 comments

I ues csh on the remote host.

The Server installation script appears to be run line by line in the login shell, and it assumes that shell is Bash.

Could the Server installation script be explicitly run in Bash?

I have attached the output with personal info redacted:

[Info  - 14:54:25.647] Resolving ssh remote authority 
[Trace  - 14:54:25.686] Identity keys:
[Info  - 14:54:25.763] Trying no-auth authentication
[Info  - 14:54:25.852] Trying publickey authentication: 
[Trace  - 14:54:26.120] Server install command:

# Server installation script

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

DISTRO_VERSION="1.95.3"
DISTRO_COMMIT="dc5a551c256719475d2d0959270e3836c9bbb632"
DISTRO_QUALITY="stable"
DISTRO_VSCODIUM_RELEASE="24321"

SERVER_APP_NAME="codium-server"
SERVER_INITIAL_EXTENSIONS=""
SERVER_LISTEN_FLAG="--port=0"
SERVER_DATA_DIR="$HOME/.vscodium-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 "c7b60a9f340694cfa9a68e51: 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 "c7b60a9f340694cfa9a68e51: 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"
        ;;
    riscv64)
        SERVER_ARCH="riscv64"
        ;;
    loongarch64)
        SERVER_ARCH="loong64"
        ;;
    s390x)
        SERVER_ARCH="s390x"
        ;;
    *)
        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

# adjust platform for vscodium download, if needed
if [[ $OS_RELEASE_ID = alpine ]]; then
    PLATFORM=$OS_RELEASE_ID
fi

SERVER_DOWNLOAD_URL="$(echo "https://github.com/VSCodium/vscodium/releases/download/\${version}.\${release}/vscodium-reh-\${os}-\${arch}-\${version}.\${release}.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
    case "$PLATFORM" in
        darwin | linux | alpine )
            ;;
        *)
            echo "Error '$PLATFORM' needs manual installation of remote extension host"
            print_install_results_and_exit 1
            ;;
    esac

    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="b5d84d77-b278-40e6-a886-f87383f66671"
    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  - 14:54:26.217] Server install command stderr:
Unmatched '''.
Bad : modifier in $ '-'.
DISTRO_VERSION=1.95.3: Command not found.
DISTRO_COMMIT=dc5a551c256719475d2d0959270e3836c9bbb632: Command not found.
DISTRO_QUALITY=stable: Command not found.
DISTRO_VSCODIUM_RELEASE=24321: Command not found.
SERVER_APP_NAME=codium-server: Command not found.
SERVER_INITIAL_EXTENSIONS=: Command not found.
SERVER_LISTEN_FLAG=--port=0: Command not found.
SERVER_DATA_DIR=*****: Command not found.
SERVER_DATA_DIR: Undefined variable.
SERVER_DIR: Undefined variable.
SERVER_DATA_DIR: Undefined variable.
SERVER_DATA_DIR: Undefined variable.
SERVER_DATA_DIR: Undefined variable.
SERVER_ARCH=: Command not found.
SERVER_CONNECTION_TOKEN=: Command not found.
SERVER_DOWNLOAD_URL=: Command not found.
LISTENING_ON=: Command not found.
OS_RELEASE_ID=: Command not found.
ARCH=: Command not found.
PLATFORM=: Command not found.
Badly placed ()'s.
LISTENING_ON: Undefined variable.
SERVER_CONNECTION_TOKEN: Undefined variable.
SERVER_LOGFILE: Undefined variable.
OS_RELEASE_ID: Undefined variable.
ARCH: Undefined variable.
PLATFORM: Undefined variable.
TMP_DIR: Undefined variable.
}: Command not found.
Illegal variable name.
KERNEL: Undefined variable.
Too many )'s.
PLATFORM=darwin: Command not found.
Too many )'s.
PLATFORM=linux: Command not found.
Too many )'s.
PLATFORM=freebsd: Command not found.
Too many )'s.
PLATFORM=dragonfly: Command not found.
Too many )'s.
KERNEL: Undefined variable.
print_install_results_and_exit: Command not found.
esac: Command not found.
Illegal variable name.
ARCH: Undefined variable.
Too many )'s.
SERVER_ARCH=x64: Command not found.
Too many )'s.
SERVER_ARCH=armhf: Command not found.
Too many )'s.
SERVER_ARCH=arm64: Command not found.
Too many )'s.
SERVER_ARCH=ppc64le: Command not found.
Too many )'s.
SERVER_ARCH=riscv64: Command not found.
Too many )'s.
SERVER_ARCH=loong64: Command not found.
Too many )'s.
SERVER_ARCH=s390x: Command not found.
Too many )'s.
ARCH: Undefined variable.
print_install_results_and_exit: Command not found.
esac: Command not found.
Illegal variable name.
OS_RELEASE_ID: Undefined variable.
Illegal variable name.
OS_RELEASE_ID: Undefined variable.
OS_RELEASE_ID=unknown: Command not found.
fi: Command not found.
fi: Command not found.
SERVER_DIR: Undefined variable.
SERVER_DIR: Undefined variable.
if: Empty if.
then: Command not found.
print_install_results_and_exit: Command not found.
fi: Command not found.
fi: Command not found.
OS_RELEASE_ID: Undefined variable.
OS_RELEASE_ID: Undefined variable.
fi: Command not found.
Illegal variable name.
SERVER_SCRIPT: Undefined variable.
PLATFORM: Undefined variable.
Too many )'s.
Too many )'s.
PLATFORM: Undefined variable.
print_install_results_and_exit: Command not found.
esac: Command not found.
SERVER_DIR: Undefined variable.
Illegal variable name.
SERVER_DOWNLOAD_URL: Undefined variable.
Illegal variable name.
SERVER_DOWNLOAD_URL: Undefined variable.
else: endif not found.

[Trace  - 14:54:26.217] Server install command stdout:
c7b60a9f340694cfa9a68e51: start
exitCode====
c7b60a9f340694cfa9a68e51: end
Error creating server install directory

[Error  - 14:54:26.218] Error resolving authority
Error: Couldn't install vscode server on remote server, install script returned non-zero exit status
	at t.installCodeServer (*****/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.47-universal/out/extension.js:1:441418)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
	at async ******/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.47-universal/out/extension.js:1:404879

fin-tsg avatar Dec 12 '24 15:12 fin-tsg

i'm having i think the same issue but with zsh

bpawnzZ avatar Jan 22 '25 04:01 bpawnzZ

same issue on zsh, the download url gets fucked

SolsticeSpectrum avatar Apr 07 '25 11:04 SolsticeSpectrum

@jeanp413 can we do a quick fix by running everything with /bin/bash?

SolsticeSpectrum avatar Apr 07 '25 11:04 SolsticeSpectrum

also on zsh and failing with same error

filo87 avatar Apr 16 '25 16:04 filo87

also on zsh and failing with same error

Deleting al the .cursor and .vscode directories from my user's home directory solved the issue for me.

filo87 avatar Apr 22 '25 07:04 filo87

same issue, no workaround

dpinhas avatar Jul 28 '25 08:07 dpinhas

same here, with csh

pomponne avatar Jul 29 '25 12:07 pomponne