diff --git a/extensions/open-remote-ssh/package.json b/extensions/open-remote-ssh/package.json index 315c432b121..1c3007c1957 100644 --- a/extensions/open-remote-ssh/package.json +++ b/extensions/open-remote-ssh/package.json @@ -103,6 +103,12 @@ "description": "**Experimental:** The name of the server binary, use this **only if** you are using a client without a corresponding server release", "scope": "application", "default": "" + }, + "remoteSSH.serverInstallPath": { + "type": "string", + "markdownDescription": "A custom directory to install the Positron server data on the remote machine. By default, the server data is installed in `~/.positron-server`.", + "scope": "application", + "default": "" } } }, diff --git a/extensions/open-remote-ssh/src/serverConfig.ts b/extensions/open-remote-ssh/src/serverConfig.ts index f4b81450e47..acc8e094f25 100644 --- a/extensions/open-remote-ssh/src/serverConfig.ts +++ b/extensions/open-remote-ssh/src/serverConfig.ts @@ -35,6 +35,7 @@ export async function getVSCodeServerConfig(): Promise { const productJson = await getVSCodeProductJson(); const customServerBinaryName = vscode.workspace.getConfiguration('remoteSSH.experimental').get('serverBinaryName', ''); + const customDataFolderName = vscode.workspace.getConfiguration('remoteSSH').get('serverInstallPath', ''); const version = `${positron.version}-${positron.buildNumber}`; @@ -44,7 +45,7 @@ export async function getVSCodeServerConfig(): Promise { quality: productJson.quality, release: productJson.release, serverApplicationName: customServerBinaryName || productJson.serverApplicationName, - serverDataFolderName: productJson.serverDataFolderName, + serverDataFolderName: customDataFolderName || productJson.serverDataFolderName, serverDownloadUrlTemplate: productJson.serverDownloadUrlTemplate }; } diff --git a/extensions/open-remote-ssh/src/serverSetup.ts b/extensions/open-remote-ssh/src/serverSetup.ts index 6a3a9596e4c..e78bd31c5b5 100644 --- a/extensions/open-remote-ssh/src/serverSetup.ts +++ b/extensions/open-remote-ssh/src/serverSetup.ts @@ -94,11 +94,15 @@ export async function installCodeServer(conn: SSHConnection, serverDownloadUrlTe let commandOutput: { stdout: string; stderr: string }; if (platform === 'windows') { + // If the default was not changed, adjust the path for PowerShell on Windows + if (installOptions.serverDataFolderName === '$HOME/.positron-server') { + installOptions.serverDataFolderName = '$HOME\\.positron-server'; + } const installServerScript = generatePowerShellInstallScript(installOptions); logger.trace('Server install command:', installServerScript); - const installDir = `$HOME\\${vscodeServerConfig.serverDataFolderName}\\install`; + const installDir = `${vscodeServerConfig.serverDataFolderName}\\install`; const installScript = `${installDir}\\${vscodeServerConfig.commit}.ps1`; const endRegex = new RegExp(`${scriptId}: end`); // investigate if it's possible to use `-EncodedCommand` flag @@ -226,7 +230,7 @@ DISTRO_VSCODIUM_RELEASE="${release ?? ''}" SERVER_APP_NAME="${serverApplicationName}" SERVER_INITIAL_EXTENSIONS="${extensions}" SERVER_LISTEN_FLAG="${useSocketPath ? `--socket-path="$TMP_DIR/vscode-server-sock-${crypto.randomUUID()}"` : '--port=0'}" -SERVER_DATA_DIR="$HOME/${serverDataFolderName}" +SERVER_DATA_DIR="${serverDataFolderName}" SERVER_DIR="$SERVER_DATA_DIR/bin/$DISTRO_COMMIT" SERVER_SCRIPT="$SERVER_DIR/bin/$SERVER_APP_NAME" SERVER_LOGFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.log" @@ -467,7 +471,7 @@ $DISTRO_VSCODIUM_RELEASE="${release ?? ''}" $SERVER_APP_NAME="${serverApplicationName}" $SERVER_INITIAL_EXTENSIONS="${extensions}" $SERVER_LISTEN_FLAG="${useSocketPath ? `--socket-path="$TMP_DIR/vscode-server-sock-${crypto.randomUUID()}"` : '--port=0'}" -$SERVER_DATA_DIR="$(Resolve-Path ~)\\${serverDataFolderName}" +$SERVER_DATA_DIR="${serverDataFolderName}" $SERVER_DIR="$SERVER_DATA_DIR\\bin\\$DISTRO_COMMIT" $SERVER_SCRIPT="$SERVER_DIR\\bin\\$SERVER_APP_NAME.cmd" $SERVER_LOGFILE="$SERVER_DATA_DIR\\.$DISTRO_COMMIT.log" diff --git a/product.json b/product.json index 3c5727d4ab8..0ea6bca49c3 100644 --- a/product.json +++ b/product.json @@ -14,7 +14,7 @@ "serverLicense": [], "serverLicensePrompt": "", "serverApplicationName": "positron-server", - "serverDataFolderName": ".positron-server", + "serverDataFolderName": "$HOME/.positron-server", "serverDownloadUrlTemplate": "https://cdn.posit.co/positron/dailies/reh/${arch-long}/positron-reh-${os}-${arch}-${version}.tar.gz", "tunnelApplicationName": "positron-tunnel", "win32DirName": "Positron",