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

tar -xf --no-same-owner Option Not Supported on OpenWrt Remote Host for Extracting VS Code Server #10603

Open
6 tasks done
mcwindy opened this issue Jan 2, 2025 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug ssh Issue in vscode-remote SSH

Comments

@mcwindy
Copy link

mcwindy commented Jan 2, 2025

Is there an existing issue for this bug?

  • I have searched the existing open issues and found none that apply.
  • If I find any issue of interest that is related or closed, I will included a link to it in this issue.

Required Troubleshooting Steps

  • I have read and performed the troubleshooting steps
  • I have tried both values of the remote.SSH.useLocalServer setting
  • My issue was not covered in the Tips and Tricks linked from the Troubleshooting Wiki.
  • I will include a complete copy of my Remote - SSH logs by running Remote-SSH: Show Log in the command palette or from View > Output in the menu bar

[Optional] Diagnose with Copilot

I asked @remote-ssh and it helped, but I still want to report this bug

In step 2 of the troubleshooting wiki, what was the result of running the generated SSH command verbatim outside of VS Code?

I COULD successfully SSH to the remote machine with the generated SSH command

Remote-SSH Log

Remote-SSH Log

10:50:32.206] Log Level: 2
[10:50:32.211] SSH Resolver called for "ssh-remote+2", attempt 1
[10:50:32.215] remote.SSH.useLocalServer = false
[10:50:32.215] remote.SSH.useExecServer = true
[10:50:32.215] remote.SSH.showLoginTerminal = false
[10:50:32.215] remote.SSH.remotePlatform = {"2":"linux","159.75.115.50":"linux","root":"linux","lighthouse":"linux","txyun":"linux","azure":"linux","azure2":"linux","azure3":"linux"}
[10:50:32.215] remote.SSH.path = 
[10:50:32.215] remote.SSH.configFile = 
[10:50:32.215] remote.SSH.useFlock = true
[10:50:32.216] remote.SSH.lockfilesInTmp = false
[10:50:32.216] remote.SSH.localServerDownload = auto
[10:50:32.216] remote.SSH.remoteServerListenOnSocket = false
[10:50:32.216] remote.SSH.defaultExtensions = []
[10:50:32.216] remote.SSH.loglevel = 2
[10:50:32.216] remote.SSH.enableDynamicForwarding = true
[10:50:32.216] remote.SSH.enableRemoteCommand = true
[10:50:32.216] remote.SSH.serverPickPortsFromRange = {}
[10:50:32.216] remote.SSH.serverInstallPath = {}
[10:50:32.216] remote.SSH.permitPtyAllocation = false
[10:50:32.216] remote.SSH.preferredLocalPortRange = undefined
[10:50:32.216] remote.SSH.useCurlAndWgetConfigurationFiles = false
[10:50:32.217] remote.SSH.experimental.chat = true
[10:50:32.217] remote.SSH.experimental.enhancedSessionLogs = true
[10:50:32.229] VS Code version: 1.96.2
[10:50:32.229] Remote-SSH version: remote-ssh@0.116.1
[10:50:32.229] linux x64
[10:50:32.231] SSH Resolver called for host: 2
[10:50:32.231] Setting up SSH remote "2"
[10:50:32.237] Using commit id "fabdb6a30b49f79a7aba0f2ad9df9b399473380f" and quality "stable" for server
[10:50:32.241] Script variables:
 {
  "ExitCode.0": "OK",
  "ExitCode.64": "LinuxPrereqs",
  "ExitCode.65": "ProxyAuthenticationRequired",
  "ExitCode.128": "UnparsableOutput",
  "ExitCode.129": "EmptyOutput",
  "ExitCode.131": "UnhandledResolverExitCode",
  "ExitCode.132": "OfflineError",
  "ExitCode.133": "SshInstall",
  "ExitCode.134": "FindLocalPort",
  "ExitCode.135": "Timeout",
  "ExitCode.136": "ExhaustedRetries",
  "ExitCode.137": "PermissionDenied",
  "ExitCode.138": "MitmPortForwardingDisabled",
  "ExitCode.139": "Canceled",
  "ExitCode.140": "BadLocalDownloadRequest",
  "ExitCode.141": "LocalDownloadFailed",
  "ExitCode.142": "LocalLockTimeout",
  "ExitCode.143": "NoBash",
  "ExitCode.144": "InvalidHostName",
  "ExitCode.145": "BadInstallScriptResult",
  "ExitCode.146": "ShellRequestFailedOnChannel",
  "ExitCode.147": "InvalidPortRange",
  "ExitCode.148": "SendDisconnectBrokenPipe",
  "ExitCode.149": "LocalServerCrashed",
  "ExitCode.150": "NoFreePortInRange",
  "ExitCode.151": "InvalidCustomServerPath",
  "ExitCode.192": "AlreadyInProgress",
  "ExitCode.193": "ServerDownloadFailed",
  "ExitCode.194": "NoDownloaderAvailable",
  "ExitCode.195": "NoDownloaderAvailableForStatusCheck",
  "ExitCode.196": "UnsupportedArch",
  "ExitCode.197": "StatusCheckFailed",
  "ExitCode.198": "NeedInsidersArch",
  "ExitCode.199": "ServerTransferFailed",
  "ExitCode.200": "ServerFailedToStart",
  "ExitCode.201": "NeedInsidersWindows",
  "ExitCode.202": "CreateInstallDirFailed",
  "ExitCode.203": "UnsupportedPlatform",
  "ExitCode.204": "ServerTerminatedCVE20201416",
  "ExitCode.205": "UnpackFailed",
  "ExitCode.206": "ChangeDirFailed",
  "ExitCode.1023": "UnclassifiedError",
  "ExitCode.OK": "0",
  "ExitCode.LinuxPrereqs": "64",
  "ExitCode.ProxyAuthenticationRequired": "65",
  "ExitCode.UnparsableOutput": "128",
  "ExitCode.EmptyOutput": "129",
  "ExitCode.UnhandledResolverExitCode": "131",
  "ExitCode.OfflineError": "132",
  "ExitCode.SshInstall": "133",
  "ExitCode.FindLocalPort": "134",
  "ExitCode.Timeout": "135",
  "ExitCode.ExhaustedRetries": "136",
  "ExitCode.PermissionDenied": "137",
  "ExitCode.MitmPortForwardingDisabled": "138",
  "ExitCode.Canceled": "139",
  "ExitCode.BadLocalDownloadRequest": "140",
  "ExitCode.LocalDownloadFailed": "141",
  "ExitCode.LocalLockTimeout": "142",
  "ExitCode.NoBash": "143",
  "ExitCode.InvalidHostName": "144",
  "ExitCode.BadInstallScriptResult": "145",
  "ExitCode.ShellRequestFailedOnChannel": "146",
  "ExitCode.InvalidPortRange": "147",
  "ExitCode.SendDisconnectBrokenPipe": "148",
  "ExitCode.LocalServerCrashed": "149",
  "ExitCode.NoFreePortInRange": "150",
  "ExitCode.InvalidCustomServerPath": "151",
  "ExitCode.AlreadyInProgress": "192",
  "ExitCode.ServerDownloadFailed": "193",
  "ExitCode.NoDownloaderAvailable": "194",
  "ExitCode.NoDownloaderAvailableForStatusCheck": "195",
  "ExitCode.UnsupportedArch": "196",
  "ExitCode.StatusCheckFailed": "197",
  "ExitCode.NeedInsidersArch": "198",
  "ExitCode.ServerTransferFailed": "199",
  "ExitCode.ServerFailedToStart": "200",
  "ExitCode.NeedInsidersWindows": "201",
  "ExitCode.CreateInstallDirFailed": "202",
  "ExitCode.UnsupportedPlatform": "203",
  "ExitCode.ServerTerminatedCVE20201416": "204",
  "ExitCode.UnpackFailed": "205",
  "ExitCode.ChangeDirFailed": "206",
  "ExitCode.UnclassifiedError": "1023",
  "InstallUnpackCode.Success": "success",
  "InstallUnpackCode.Error": "error",
  "InstallUnpackCode.MissingFiles": "missingFiles",
  "uuid": "0fb7d2cabd79",
  "startMarker": "0fb7d2cabd79: running",
  "commitId": "fabdb6a30b49f79a7aba0f2ad9df9b399473380f",
  "quality": "stable",
  "token": "a1aaaaa1-a111-1a1a-111a-111111111aaa",
  "vscodeAgentFolder": "$HOME/.vscode-server",
  "allowClientDownload": "1",
  "forceClientDownload": "0",
  "cliNameInArchive": "code",
  "ignoreWgetConfigFlag": " --no-config ",
  "ignoreCurlConfigFlag": " --disable ",
  "wgetTriesSegment": "--tries=1",
  "listenArgs": "--on-host=127.0.0.1 --on-port",
  "getDownloadServerStartTrigger": "0fb7d2cabd79:trigger_server_download",
  "getDownloadServerEndTrigger": "0fb7d2cabd79:trigger_server_download_end",
  "getProgressDownloading": "0fb7d2cabd79%%1%%",
  "getProgressInstalling": "0fb7d2cabd79%%2%%",
  "printVars": "echo \"SSH_AUTH_SOCK==$SSH_AUTH_SOCK==\"\necho \"DISPLAY==$DISPLAY==\""
}
[10:50:32.243] Install and start server if needed
[10:50:32.247] PATH: /home/mcwindy/.bun/bin:/home/mcwindy/.deno/bin:/home/mcwindy/.nvm/versions/node/v22.9.0/bin:/home/mcwindy/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
[10:50:32.247] Checking ssh with "ssh -V"
[10:50:32.263] > OpenSSH_9.7p1 Ubuntu-7ubuntu4, OpenSSL 3.3.1 4 Jun 2024

[10:50:32.267] Running script with connection command: ssh -T -D 33339 -o ConnectTimeout=15 2 sh
[10:50:32.267] Generated SSH command: 'ssh -T -D 33339 -o ConnectTimeout=15 2 sh << 'EOSSH'
# shellcheck shell=sh

echo "0fb7d2cabd79: running"
echo "Script executing under PID: $$"

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

# Configuration
UUID="0fb7d2cabd79"
COMMIT_ID="fabdb6a30b49f79a7aba0f2ad9df9b399473380f"
QUALITY="stable"
TOKEN="d0dfeef5-c991-4f6a-837f-822441760bcc"
VSCODE_AGENT_FOLDER="$HOME/.vscode-server"
ALLOW_CLIENT_DOWNLOAD="1"
FORCE_CLIENT_DOWNLOAD="0"
CLI_NAME_IN_ARCHIVE="code"
IGNORE_WGET_CONFIG_FLAG=" --no-config "
IGNORE_CURL_CONFIG_FLAG=" --disable "
WGET_TRIES_SEGMENT="--tries=1"
LISTEN_ARGS="--on-host=127.0.0.1 --on-port"

CLI_NAME_ON_DISK="${CLI_NAME_IN_ARCHIVE}-${COMMIT_ID}"
CLI_PATH="${VSCODE_AGENT_FOLDER}/${CLI_NAME_ON_DISK}"
CLI_LOG_FILE="${VSCODE_AGENT_FOLDER}/.cli.${COMMIT_ID}.log"

# Marker strings
GET_DOWNLOAD_SERVER_START_TRIGGER="0fb7d2cabd79:trigger_server_download"
GET_DOWNLOAD_SERVER_END_TRIGGER="0fb7d2cabd79:trigger_server_download_end"
GET_PROGRESS_DOWNLOADING="0fb7d2cabd79%%1%%"
GET_PROGRESS_INSTALLING="0fb7d2cabd79%%2%%"

UNPACK_RESULT=
DID_LOCAL_DOWNLOAD=0
DOWNLOAD_TIME=
INSTALL_TIME=
SERVER_START_TIME=

fail_with_exitcode() {
	echo "${UUID}: start"
	echo "exitCode==$1=="
	echo_common_results
	echo "${UUID}: end"
	exit 0
}

echo_common_results() {
	echo "listeningOn==$LISTENING_ON=="
	echo "osReleaseId==$OSRELEASEID=="
	echo "arch==$ARCH=="
	echo "vscodeArch==$VSCODE_ARCH=="
	echo "bitness==$BITNESS=="
	echo "tmpDir==$VSC_TMP=="
	echo "platform==$PLATFORM=="
	echo "unpackResult==$UNPACK_RESULT=="
	echo "didLocalDownload==$DID_LOCAL_DOWNLOAD=="
	echo "downloadTime==$DOWNLOAD_TIME=="
	echo "installTime==$INSTALL_TIME=="
	echo "serverStartTime==$SERVER_START_TIME=="
	echo "execServerToken==${TOKEN}=="
	echo "platformDownloadPath==$PLATFORM_DOWNLOAD_PATH=="
	echo "SSH_AUTH_SOCK==$SSH_AUTH_SOCK=="
echo "DISPLAY==$DISPLAY=="
}

millis() {
	d=$(date +%s%N)
	# Test if 'd' contains any non-digit characters
	if [ -z "${d##*[!0-9]*}" ] || [ "$PLATFORM" != "linux" ]; then
	    # Fallback for MacOS or any date binary that doesn't handle '%N'
		echo $(($(date +%s)*1000))
		return
	fi
	echo $((d/1000000))
}

elapsed() {
	echo $(($(millis) - $1))
}

printenv_indent() {
	echo "printenv:"
	printenv | sed 's/^/    /'
}

#
# Get OS name
#
OSRELEASEID=$(cat /etc/os-release 2>/dev/null | grep -a -E '^ID=' | sed 's/^[Ii][Dd]=//g' | sed 's/"//g')
if [ -z "$OSRELEASEID" ]
then
	OSRELEASEID=$(cat /usr/lib/os-release 2>/dev/null | grep -a -E '^ID=' | sed 's/^[Ii][Dd]=//g' | sed 's/"//g')
	if [ -z "$OSRELEASEID" ]
	then
		OSRELEASEID=$(uname -s)
	fi
fi

#
# Get host platform/architecture
#
UNAME=$(uname -s)
case $UNAME in
	Linux) PLATFORM=linux;;
	Darwin) PLATFORM=macOS;;
	*)
		echo "Unsupported platform: $UNAME"
		fail_with_exitcode 203
		;;
esac

BITNESS=$(getconf LONG_BIT)
ARCH=$(uname -m)
case $ARCH in
	x86_64) VSCODE_ARCH="x64";;
	armv7l | armv8l)
		VSCODE_ARCH="armhf"
		;;
	arm64 | aarch64)
		if [ "$BITNESS" = 32 ]; then
			# Can have 32-bit userland on 64-bit kernel
			VSCODE_ARCH="armhf"
		else
			VSCODE_ARCH="arm64"
		fi
		;;
	*)
		OSRELEASE=$(uname -r)
		case $OSRELEASE in
			*x86_64*) VSCODE_ARCH="x64";;
			*)
				echo "Unsupported architecture: $ARCH"
				fail_with_exitcode 196
			;;
		esac
		;;
esac

if [ "$PLATFORM" = linux ]; then
	if [ "$VSCODE_ARCH" = armhf ]; then
		PLATFORM_DOWNLOAD_PATH=cli-linux-armhf
	else
		PLATFORM_DOWNLOAD_PATH=cli-alpine-$VSCODE_ARCH
	fi
elif [ "$VSCODE_ARCH" = "arm64" ]; then
	PLATFORM_DOWNLOAD_PATH=cli-darwin-arm64
else
	PLATFORM_DOWNLOAD_PATH=cli-darwin-x64
fi

if [ ! -d "$VSCODE_AGENT_FOLDER" ]; then
	mkdir -p "$VSCODE_AGENT_FOLDER"
	chmod 750 "$VSCODE_AGENT_FOLDER"

	error_code=$?
	if [ "${error_code}" -gt 0 ]; then
		echo "Creating the server install dir failed..."
		fail_with_exitcode 202
	fi
fi

#
# Delete old CLIs if needed
#

# shellcheck disable=SC2010
TO_DELETE=$(ls -1 -t "$VSCODE_AGENT_FOLDER" | grep -E "code(-insiders)?-[a-fA-F0-9]{40}" | tail -n +6)
for CLI_TO_DELETE in $TO_DELETE; do
	target_dir="$VSCODE_AGENT_FOLDER/$CLI_TO_DELETE"
	echo "Deleting old install $target_dir"
	rm -rf "$target_dir"
done

do_client_download() {
	DID_LOCAL_DOWNLOAD=1
	echo "Trigger local server download"
	echo "${GET_DOWNLOAD_SERVER_START_TRIGGER}"
	echo artifact==$PLATFORM_DOWNLOAD_PATH==
	echo destFolder==$VSCODE_AGENT_FOLDER==
	echo destFolder2==/vscode-cli-$COMMIT_ID.tar.gz==
	echo "${GET_DOWNLOAD_SERVER_END_TRIGGER}"
	echo "Waiting for client to transfer server archive..."
	echo "Waiting for $VSCODE_AGENT_FOLDER/vscode-cli-$COMMIT_ID.tar.gz.done and vscode-server.tar.gz to exist"

	while true; do
		if [ -f "$VSCODE_AGENT_FOLDER/vscode-cli-$COMMIT_ID.tar.gz.done" ]; then
			if [ ! -f "$VSCODE_AGENT_FOLDER/vscode-cli-$COMMIT_ID.tar.gz" ]; then
				echo "Found flag but not server tar - server transfer failed"
				fail_with_exitcode 199
			fi

			echo "Found flag and server on host"
			rm "$VSCODE_AGENT_FOLDER/vscode-cli-$COMMIT_ID.tar.gz.done"
			break
		else
			printf ' '
			sleep 3
		fi
	done
}

do_client_download_or_fail() {
	error_code="${1:-"1"}"
	if [ "$DID_LOCAL_DOWNLOAD" = "1" ]; then
		echo "Already attempted local download, failing"
		fail_with_exitcode "$error_code"
	elif [ $ALLOW_CLIENT_DOWNLOAD = "1" ]; then
		do_client_download
	else
		fail_with_exitcode "$error_code"
	fi
}

is_program_from_busybox() {
	program=$1
	if command -v busybox > /dev/null 2>&1
	then
		# Check symlink from program to busybox
		if [ -L "$(command -v "$program")" ] && [ "$(readlink -f "$(command -v "$program")")" = "$(command -v busybox)" ]
		then
			echo "Program '$program' is provided by busybox" >&2
			echo 'yes'
			return
		fi
	fi
	echo 'no'
}

supports_flag() {
    program="$1"
    flag="$2"

    if command -v "$program" > /dev/null 2>&1; then
        if "$program" --help 2>&1 | grep -q -- "$flag"
		then
			echo "Program '$program' appears to support flag '$flag'" >&2
			echo 'yes'
			return
		fi
    fi
		echo "Program '$program' is not available or does not appear to support flag '$flag'" >&2
        echo 'no'
}

do_host_download() {
	start=$(millis)
	echo "${GET_PROGRESS_DOWNLOADING}"

	DOWNLOAD_URL=http://222.178.203.72:19005/whst/63/=tocZsdzbncdzuhrtZkrstchnzbnl//commit:$COMMIT_ID/$PLATFORM_DOWNLOAD_PATH/${QUALITY}

	if command -v wget > /dev/null 2>&1
	then
		echo "Downloading with wget"
		IS_WGET_BUSYBOX=$(is_program_from_busybox wget)

		echo "wget is from busybox: $IS_WGET_BUSYBOX"

		if [ "$IS_WGET_BUSYBOX" = 'no' ]
		then
			# Not busybox.
			# Assuming its GNU wget or similar

			if [ -n "$IGNORE_WGET_CONFIG_FLAG" ] && [ "$(supports_flag 'wget' '--no-config')" = "no" ]; then
				echo "Detected that this version of wget does not support '--no-config'. Will not ignore wget default configuration files."
				IGNORE_WGET_CONFIG_FLAG=""
			fi

			WGET_ERRORS=$(2>&1 wget ${IGNORE_WGET_CONFIG_FLAG} ${WGET_TRIES_SEGMENT} --connect-timeout=7 --dns-timeout=7 -nv -O vscode-cli-$COMMIT_ID.tar.gz ${DOWNLOAD_URL})
		else
			# Is busybox.
			# Remove flags for the sake of compatibility

			WGET_ERRORS=$(2>&1 wget -O vscode-cli-$COMMIT_ID.tar.gz ${DOWNLOAD_URL})
		fi

		error_code=$?
		if [ $error_code -ne 0 ]
		then
			echo "wget download failed"
			echo "$WGET_ERRORS"
			printenv_indent

			do_client_download_or_fail 193
		else
			echo "Download complete"
			DOWNLOAD_TIME=$(elapsed $start)
		fi
	else
		command -v curl > /dev/null 2>&1
		error_code=$?
		if [ $error_code -eq 0 ]
		then
			echo "Downloading with curl"
			CURL_STATUS_CODE_RESULT=$(curl ${IGNORE_CURL_CONFIG_FLAG} --connect-timeout 7 -L $DOWNLOAD_URL --output vscode-cli-$COMMIT_ID.tar.gz -w "%{http_code}")
			error_code=$?
			curl_status_code_if_2xx=$(echo "$CURL_STATUS_CODE_RESULT" | grep -E "^2[0-9]{2}$")
			if [ $error_code -ne 0 ] || [ -z "$curl_status_code_if_2xx" ]
			then
				echo "curl download failed"
				echo "HTTP status code: $CURL_STATUS_CODE_RESULT"
				printenv_indent

				do_client_download_or_fail 193
			else
				echo "Download complete"
				DOWNLOAD_TIME=$(elapsed $start)
			fi
		else
			printenv_indent
			echo "Neither wget nor curl is installed"

			do_client_download_or_fail 194
		fi
	fi
}

do_install() {
	start=$(millis)
	echo "${GET_PROGRESS_INSTALLING}"
	UNPACK_RESULT="success"
	echo "tar --version: $(tar --version)"
	tar -xf vscode-cli-$COMMIT_ID.tar.gz --no-same-owner
	TAR_EXIT=$?
	INSTALL_TIME=$(elapsed $start)

	if [ $TAR_EXIT -ne 0 ]
	then
		echo "ERROR: tar exited with a non-zero exit code: $TAR_EXIT"
		UNPACK_RESULT="error"
		do_client_download_or_fail "205"
		do_install
		return
	fi

	mv "$CLI_NAME_IN_ARCHIVE" "$CLI_PATH"

	# cheap sanity check

	if ! eval "$CLI_PATH --version"
	then
		UNPACK_RESULT="missingFiles"
		echo "ERROR: $CLI_PATH don't exist"
		do_client_download_or_fail "205"
		do_install
		return
	fi

	# Delete the leftover folder which might have -web prefix, and the .tar.gz
	rm -rf vscode-cli*
}

#
# Install if needed
#
if [ ! -f "$CLI_PATH" ]
then
	echo "Installing to $VSCODE_AGENT_FOLDER..."
	STASHED_WORKING_DIR="$(pwd)"
	cd "$VSCODE_AGENT_FOLDER" || fail_with_exitcode 206

	if [ $FORCE_CLIENT_DOWNLOAD = "1" ]; then
		do_client_download
	else
		do_host_download
	fi

	do_install
	cd "$STASHED_WORKING_DIR" || fail_with_exitcode 206
else
	echo "Found existing installation at $VSCODE_AGENT_FOLDER..."
fi


#
# Start the server
#
start_server() {
	echo "Starting VS Code CLI..."
	printenv_indent
	start=$(millis)
	if [ -f $CLI_LOG_FILE ]; then
		echo "Removing old logfile at $CLI_LOG_FILE"
		rm "$CLI_LOG_FILE" # See #6265
	fi

	# Stop exporting VSCODE_AGENT_FOLDER once https://github.com/microsoft/vscode/pull/228287 is available and replace with:
	# --extensions-dir "$VSCODE_AGENT_FOLDER/extensions" --user-data-dir "$VSCODE_AGENT_FOLDER/data"
	# See https://github.com/microsoft/vscode-internalbacklog/issues/2604, https://github.com/microsoft/vscode-remote-release/issues/10255
	export VSCODE_AGENT_FOLDER

	touch $CLI_LOG_FILE
	chmod 600 $CLI_LOG_FILE

	VSCODE_CLI_REQUIRE_TOKEN=${TOKEN} "$CLI_PATH" command-shell --cli-data-dir "$VSCODE_AGENT_FOLDER/cli" --parent-process-id $$ ${LISTEN_ARGS} > "$CLI_LOG_FILE" 2>&1 < /dev/null &
	CLI_PID=$!
	echo "Spawned remote CLI: $!"

	count=0
	max_retries=15
	while [ $count -lt $max_retries ]; do
		count=$((count + 1))
		LISTENING_ON=$(cat "$CLI_LOG_FILE" | grep -a -E 'Listening on .+' | grep -v grep | sed 's/Listening on //')
		if [ "$LISTENING_ON" != '' ]
		then
			break
		fi

		# "If sig is 0 (the null signal), error checking is performed but no signal is actually sent.
		# The null signal can be used to check the validity of pid.""
		# Source: https://pubs.opengroup.org/onlinepubs/007908799/xsh/kill.html
		if ! kill -0 $CLI_PID > /dev/null; then
			echo "Exec server process not found"
			cat $CLI_LOG_FILE
			break
		fi

		echo "Waiting for server log..."
		sleep .03
	done
	SERVER_START_TIME=$(elapsed $start)
}

start_server

# What we echo below cannot be wider than 80 characters
echo "${UUID}: start"
echo_common_results
echo "${UUID}: end"

while true; do sleep 180; printf ' '; done

EOSSH'
[10:50:32.268] Using connect timeout of 17 seconds
[10:50:32.775] > root@10.160.34.2's password: 
[10:50:32.775] Got some output, clearing connection timeout
[10:50:32.776] Showing password prompt
[10:50:35.989] Got password response
[10:50:35.989] "install" wrote data to terminal: "*********"
[10:50:36.003] > 
[10:50:36.059] > 0fb7d2cabd79: running
> Script executing under PID: 32269
> sh: getconf: not found
[10:50:36.067] > Installing to /root/.vscode-server...
> 0fb7d2cabd79%%1%%
> Downloading with wget
> wget is from busybox: no
[10:50:36.186] > Program 'wget' is not available or does not appear to support flag '--no-config'
> Detected that this version of wget does not support '--no-config'. Will not ignore wget default configuration files.
[10:50:36.301] > wget download failed
> wget: unrecognized option: tries=1
> Usage: wget [options] <URL>
> Options:
> 	-4				Use IPv4 only
> 	-6				Use IPv6 only
> 	-O <file>			Redirect output to file (use "-" for stdout)
> 	-P <dir>			Set directory for output files
> 	--quiet | -q			Turn off status messages
> 	--continue | -c			Continue a partially-downloaded file
> 	--user=<user>			HTTP authentication username
> 	--password=<password>		HTTP authentication password
> 	--user-agent | -U <str>		Set HTTP user agent
> 	--post-data=STRING		use the POST method; send STRING as the data
> 	--post-file=FILE		use the POST method; send FILE as the data
> 	--spider | -s			Spider mode - only check file existence
> 	--timeout=N | -T N		Set connect/request timeout to N seconds
> 	--proxy=on | -Y on		Enable interpretation of proxy env vars (default)
> 	--proxy=off | -Y off |
> 	--no-proxy           		Disable interpretation of proxy env vars
> 
> HTTPS options:
> 	--ca-certificate=<cert>		Load CA certificates from file <cert>
> 	--no-check-certificate		don't validate the server's certificate
> 	--ciphers=<cipherlist>		Set the cipher list string
> printenv:
> sh: printenv: not found
> Trigger local server download
> 0fb7d2cabd79:trigger_server_download
> artifact==cli-alpine-x64==
> destFolder==/root/.vscode-server==
> destFolder2==/vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz==
> 0fb7d2cabd79:trigger_server_download_end
> Waiting for client to transfer server archive...
> Waiting for /root/.vscode-server/vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz.done and vscode-server.tar.gz to exist
>  
[10:50:36.302] Got request to download on client for {"artifact":"cli-alpine-x64","destPath":"/root/.vscode-server/vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz"}
[10:50:36.302] server download URL: http://222.178.203.72:19005/whst/63/=tocZsdzbncdzuhrtZkrstchnzbnl//commit:fabdb6a30b49f79a7aba0f2ad9df9b399473380f/cli-alpine-x64/stable
[10:50:36.303] Downloading VS Code server locally...
[10:50:37.495] Downloaded VS Code server to /tmp/e3ffa2c3-6edd-4674-a637-6354f17e676d
[10:50:37.495] Renamed VS Code server to /tmp/vscode_server_1735786237495/vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz
[10:50:37.496] Preparing to scp to host 2
[10:50:37.497] PATH: /home/mcwindy/.bun/bin:/home/mcwindy/.deno/bin:/home/mcwindy/.nvm/versions/node/v22.9.0/bin:/home/mcwindy/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
[10:50:37.497] Checking ssh with "ssh -V"
[10:50:37.507] > OpenSSH_9.7p1 Ubuntu-7ubuntu4, OpenSSL 3.3.1 4 Jun 2024

[10:50:37.507] Testing scp with "scp"
[10:50:37.515] scp exited with code: 1
[10:50:37.515] Got stderr from scp: usage: scp [-346ABCOpqRrsTv] [-c cipher] [-D sftp_server_path] [-F ssh_config]
           [-i identity_file] [-J destination] [-l limit] [-o ssh_option]
           [-P port] [-S program] [-X sftp_option] source ... target
[10:50:37.516] Copying file to remote with scp -o ConnectTimeout=15 'vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz' 'vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz.done' 2:'/root/.vscode-server'
[10:50:37.516] Using cwd: file:///tmp/vscode_server_1735786237495
[10:50:37.912] > root@10.160.34.2's password: 
[10:50:37.912] Showing password prompt
[10:50:50.475] Got password response
[10:50:50.476] "Copy server to host" wrote data to terminal: "*********"
[10:50:50.490] > 
[10:50:50.543] > vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b3994   0%    0     0.0KB/s   --:-- ETA
[10:50:50.837] > vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b3994 100% 8834KB  29.3MB/s   00:00    
> vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b3994   0%    0     0.0KB/s   --:-- ETAvscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b3994 100%    9    44.1KB/s   00:00    
[10:50:51.081] "Copy server to host" terminal command done
[10:50:51.306] > Found flag and server on host
> 0fb7d2cabd79%%2%%
> tar
[10:50:51.316] > : unrecognized option: version
> BusyBox v1.36.1 (2023-11-19 17:02:49 UTC) multi-call binary.
> 
> Usage: tar c|x|t [-zahvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE] [FILE]...
> 
> Create, extract, or list files from a tar file
> 
> 	c	Create
> 	x	Extract
> 	t	List
> 	-f FILE	Name of TARFILE ('-' for stdin/out)
> 	-C DIR	Change to DIR before operation
> 	-v	Verbose
> 	-O	Extract to stdout
> 	-o	Don't restore user:group
> 	-k	Don't replace existing files
> 	-z	(De)compress using gzip
> 	-a	(De)compress based on extension
> 	-h	Follow symlinks
> 	-T FILE	File with names to include
> 	-X FILE	File with glob patterns to exclude
> tar --version: 
> tar: unrecognized option: no-same-owner
> BusyBox v1.36.1 (2023-11-19 17:02:49 UTC) multi-call binary.
> 
> Usage: tar c|x|t [-zahvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE] [FILE]...
> 
> Create, extract, or list files from a tar file
> 
> 	c	Create
> 	x	Extract
> 	t	List
> 	-f FILE	Name of TARFILE ('-' for stdin/out)
> 	-C DIR	Change to DIR before operation
> 	-v	Verbose
> 	-O	Extract to stdout
> 	-o	Don't restore user:group
> 	-k	Don't replace existing files
> 	-z	(De)compress using gzip
> 	-a	(De)compress based on extension
> 	-h	Follow symlinks
> 	-T FILE	File with names to include
> 	-X FILE	File with glob patterns to exclude
[10:50:51.321] > ERROR: tar exited with a non-zero exit code: 1
> Already attempted local download, failing
> 0fb7d2cabd79: start
> exitCode==205==
> listeningOn====
> osReleaseId==immortalwrt==
> arch==x86_64==
> vscodeArch==x64==
> bitness====
> tmpDir==/tmp==
> platform==linux==
> unpackResult==error==
> didLocalDownload==1==
> downloadTime====
> installTime==0==
> serverStartTime====
> execServerToken==a1aaaaa1-a111-1a1a-111a-111111111aaa==
> platformDownloadPath==cli-alpine-x64==
> SSH_AUTH_SOCK====
> DISPLAY====
> 0fb7d2cabd79: end
[10:50:51.321] Received install output: 
exitCode==205==
listeningOn====
osReleaseId==immortalwrt==
arch==x86_64==
vscodeArch==x64==
bitness====
tmpDir==/tmp==
platform==linux==
unpackResult==error==
didLocalDownload==1==
downloadTime====
installTime==0==
serverStartTime====
execServerToken==a1aaaaa1-a111-1a1a-111a-111111111aaa==
platformDownloadPath==cli-alpine-x64==
SSH_AUTH_SOCK====
DISPLAY====

[10:50:51.323] Resolver error: Error: Unable to install VS Code server
	at v.ServerInstallError (/home/mcwindy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.116.1/out/extension.js:2:696442)
	at f (/home/mcwindy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.116.1/out/extension.js:2:691374)
	at t.handleInstallOutput (/home/mcwindy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.116.1/out/extension.js:2:692563)
	at t.tryInstall (/home/mcwindy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.116.1/out/extension.js:2:812473)
	at async /home/mcwindy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.116.1/out/extension.js:2:771431
	at async t.withShowDetailsEvent (/home/mcwindy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.116.1/out/extension.js:2:774668)
	at async x (/home/mcwindy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.116.1/out/extension.js:2:768087)
	at async t.resolve (/home/mcwindy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.116.1/out/extension.js:2:772083)
	at async /home/mcwindy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.116.1/out/extension.js:2:1055245
[10:50:51.325] ------

Expected Behavior

tar successfully unzip the code-cli-$COMMIT_ID.tar.gz

I tried the snippet below, and it allows me to successfully establish connection.

COMMIT_ID="fabdb6a30b49f79a7aba0f2ad9df9b399473380f"
wget https://update.code.visualstudio.com/commit:$COMMIT_ID/cli-alpine-x64/stable -O vscode-server.tar.gz
mkdir ~/.vscode-server/ && cd ~/.vscode-server/
tar -xzf vscode-server.tar.gz -o
mv code code-$COMMIT_ID
root@ImmortalWrt:~/.vscode-server# tar -xf vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz --no-same-owner
tar: unrecognized option: no-same-owner
BusyBox v1.36.1 (2023-11-19 17:02:49 UTC) multi-call binary.

Usage: tar c|x|t [-zahvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE] [FILE]...

Create, extract, or list files from a tar file

	c	Create
	x	Extract
	t	List
	-f FILE	Name of TARFILE ('-' for stdin/out)
	-C DIR	Change to DIR before operation
	-v	Verbose
	-O	Extract to stdout
	-o	Don't restore user:group
	-k	Don't replace existing files
	-z	(De)compress using gzip
	-a	(De)compress based on extension
	-h	Follow symlinks
	-T FILE	File with names to include
	-X FILE	File with glob patterns to exclude
root@ImmortalWrt:~/.vscode-server# tar -xf vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz -o
tar: invalid tar magic
root@ImmortalWrt:~/.vscode-server# tar -xzf vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz -o
root@ImmortalWrt:~/.vscode-server# l
-rwxrwxr-x    1 root     root      22070072 Dec 19 18:29 code*
-rw-r--r--    1 root     root       9046413 Jan  2 10:11 vscode-cli-fabdb6a30b49f79a7aba0f2ad9df9b399473380f.tar.gz

Actual Behavior

In the script tar -xf vscode-cli-$COMMIT_ID.tar.gz --no-same-owner is used to unzip the gz, which do not work in remote host like openwrt.

Steps To Reproduce

Create a machine with OS Immortalwrt and try to connect to that host.

Anything else?

No response

@mcwindy mcwindy added the ssh Issue in vscode-remote SSH label Jan 2, 2025
@joshspicer joshspicer added the bug Issue identified by VS Code Team member as probable bug label Jan 6, 2025
@joshspicer
Copy link
Member

Thank you for the detailed report. We already have some code to attempt to detect more minimal environments (reducing flags for busybox-flavors of common tools). I'm surprised we haven't hit this before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

2 participants