You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Windows 10, trying to connect Debian on WSL2.
Connecting to WSL is broken, as the installation script is passed via wsl.exe ...cli-options... -- bash -c '.....script-content...', where script-content contains single quotes. Obviously, the first single quote inside the script will terminate the one launched in the shell running that wsl command, leading to an unrecoverable error.
It especially does not make sense, as those single quotes can be replaced with double quotes, without causing issues, as far as I have checked.
Workaround
I hotfix patched the extension.js @ "C:\Users\USERNAME\.vscode-oss\extensions\jeanp413.open-remote-wsl-0.0.4-universal\out\extension.js" with the following content.
(()=>{"use strict";vare={618:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.RemoteWSLResolver=t.getRemoteAuthority=t.REMOTE_WSL_AUTHORITY=void0;consts=i(n(496)),a=n(744);t.REMOTE_WSL_AUTHORITY="wsl",t.getRemoteAuthority=function(e){return`${t.REMOTE_WSL_AUTHORITY}+${e}`};classl{constructor(e,t){this.remoteAddress=e,this.localAddress=t,this._onDidDisposeEmitter=news.EventEmitter,this.onDidDispose=this._onDidDisposeEmitter.event,"localhost"!==t.host&&"127.0.0.1"!==t.host&&(t.host="localhost")}dispose(){this._onDidDisposeEmitter.fire()}}t.RemoteWSLResolver=class{constructor(e,t){this.wslManager=e,this.logger=t}resolve(e,n){const[r,o]=e.split("+");if(r!==t.REMOTE_WSL_AUTHORITY)thrownewError(`Invalid authority type for WSL resolver: ${r}`);this.logger.info(`Resolving wsl remote authority '${e}' (attemp #${n.resolveAttempt})`);consti=s.workspace.getConfiguration("remote.WSL").get("serverDownloadUrlTemplate");returns.window.withProgress({title:`Setting up WSL Distro: ${o}`,location:s.ProgressLocation.Notification,cancellable:!1},(async()=>{try{conste=await(0,a.installCodeServer)(this.wslManager,o,i,[],[],this.logger);returnthis.labelFormatterDisposable?.dispose(),this.labelFormatterDisposable=s.workspace.registerResourceLabelFormatter({scheme:"vscode-remote",authority:`${t.REMOTE_WSL_AUTHORITY}+*`,formatting:{label:"${path}",separator:"/",tildify:!0,workspaceSuffix:`WSL: ${o}`,workspaceTooltip:`Running in ${o}`}}),news.ResolvedAuthority("127.0.0.1",e.listeningOn,e.connectionToken)}catch(e){if(this.logger.error("Error resolving authority",e),1===n.resolveAttempt){this.logger.show();conste="Close Remote",t="Retry",n=awaits.window.showErrorMessage(`Could not establish connection to WSL distro "${o}"`,{modal:!0},e,t);n===e?awaits.commands.executeCommand("workbench.action.remote.close"):n===t&&awaits.commands.executeCommand("workbench.action.reloadWindow")}throweinstanceofa.ServerInstallError||!(einstanceofError)?s.RemoteAuthorityResolverError.NotAvailable(einstanceofError?e.message:String(e)):s.RemoteAuthorityResolverError.TemporarilyNotAvailable(e.message)}}))}asynctunnelFactory(e){returnnewl(e.remoteAddress,{host:e.remoteAddress.host,port:e.localAddressPort??e.remoteAddress.port})}dispose(){this.labelFormatterDisposable?.dispose()}}},49:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t},s=this&&this.__importDefault||function(e){returne&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteWSLDistro=t.setDefaultWSLDistro=t.openRemoteWSLLocationWindow=t.openRemoteWSLWindow=t.promptInstallNewWSLDistro=t.promptOpenRemoteWSLWindow=void0;consta=i(n(496)),l=n(618),c=s(n(574));functiond(e,t){a.commands.executeCommand("vscode.newWindow",{remoteAuthority:(0,l.getRemoteAuthority)(e),reuseWindow:t})}t.promptOpenRemoteWSLWindow=asyncfunction(e,t,n){letr;if(t){constt=awaite.listDistros();r=t.find((e=>e.isDefault))?.name}elser=(awaitasyncfunction(e,t){constn=e.listDistros().then((e=>e.map((e=>({...e,label:`${e.name}`,detail:e.isDefault?"default distro":void0})))));returnawaita.window.showQuickPick(n,{canPickMany:!1,placeHolder:"Select WSL distro"})}(e))?.name;r&&d(r,n)},t.promptInstallNewWSLDistro=asyncfunction(e){lett;t=(awaitasyncfunction(e,t){constn=Promise.all([e.listOnlineDistros(),e.listDistros()]).then((([e,t])=>e.filter((e=>!t.some((t=>t.name===e.name)))).map((e=>({...e,label:`${e.friendlyName}`})))));returnawaita.window.showQuickPick(n,{canPickMany:!1,placeHolder:"Select the WSL distro to install"})}(e))?.name,t&&c.default.runCommand(`wsl.exe --install -d ${t}`)},t.openRemoteWSLWindow=d,t.openRemoteWSLLocationWindow=function(e,t,n){a.commands.executeCommand("vscode.openFolder",a.Uri.from({scheme:"vscode-remote",authority:(0,l.getRemoteAuthority)(e),path:t}),{forceNewWindow:!n})},t.setDefaultWSLDistro=asyncfunction(e,t){awaite.setDefaultDistro(t)},t.deleteWSLDistro=asyncfunction(e,t){constn="Delete";returnawaita.window.showInformationMessage(`Are you sure you want to permanently delete the distro "${t}" including all its data?`,{modal:!0},n)===n&&(awaite.deleteDistro(t),!0)}},771:(e,t)=>{functionn(e){for(;e.length;){constt=e.pop();t&&t.dispose()}}Object.defineProperty(t,"__esModule",{value:!0}),t.Disposable=t.disposeAll=void0,t.disposeAll=n,t.Disposable=class{constructor(){this._isDisposed=!1,this._disposables=[]}dispose(){this._isDisposed||(this._isDisposed=!0,n(this._disposables))}_register(e){returnthis._isDisposed?e.dispose():this._disposables.push(e),e}getisDisposed(){returnthis._isDisposed}}},110:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventEmitter=t.once=t.toPromise=void0,t.toPromise=function(e,n){returnn?n.aborted?Promise.resolve(void0):newPromise((r=>{consto=(0,t.once)(e,(e=>{n.removeEventListener("abort",i),r(e)})),i=()=>{o.dispose(),n.removeEventListener("abort",i),r(void0)};n.addEventListener("abort",i)})):newPromise((n=>(0,t.once)(e,n)))},t.once=(e,t)=>{constn=e((e=>{t(e),n.dispose()}));returnn},t.EventEmitter=class{constructor(){this.event=(e,t,n)=>{constr=this.add(t?e.bind(t):e);returnn?.push(r),r}}getsize(){returnthis.listeners?"function"==typeofthis.listeners?1:this.listeners.length:0}fire(e){if(this.listeners)if("function"==typeofthis.listeners)this.listeners(e);elsefor(consttofthis.listeners)t(e)}dispose(){this.listeners=void0}add(e){returnthis.listeners?"function"==typeofthis.listeners?this.listeners=[this.listeners,e]:this.listeners.push(e):this.listeners=e,{dispose:()=>this.rm(e)}}rm(e){if(!this.listeners)return;if("function"==typeofthis.listeners)returnvoid(this.listeners===e&&(this.listeners=void0));constt=this.listeners.indexOf(e);-1!==t&&(2===this.listeners.length?this.listeners=0===t?this.listeners[1]:this.listeners[0]:this.listeners=this.listeners.slice(0,t).concat(this.listeners.slice(t+1)))}}},249:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});consts=i(n(496));functiona(e,t,n=" "){returnn.repeat(Math.max(0,t-e.length))+e}t.default=class{constructor(e){this.output=s.window.createOutputChannel(e)}data2String(e){returneinstanceofError?e.stack||e.message:!1===e.success&&e.message?e.message:e.toString()}trace(e,t){this.logLevel("Trace",e,t)}info(e,t){this.logLevel("Info",e,t)}error(e,t){this.logLevel("Error",e,t)}logLevel(e,t,n){this.output.appendLine(`[${e} - ${this.now()}] ${t}`),n&&this.output.appendLine(this.data2String(n))}now(){conste=newDate;returna(e.getUTCHours()+"",2,"0")+":"+a(e.getMinutes()+"",2,"0")+":"+a(e.getUTCSeconds()+"",2,"0")+"."+e.getMilliseconds()}show(){this.output.show()}dispose(){this.output.dispose()}}},400:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLinux=t.isMacintosh=t.isWindows=void0,t.isWindows="win32"===process.platform,t.isMacintosh="darwin"===process.platform,t.isLinux="linux"===process.platform},679:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.DistroTreeDataProvider=void0;consts=i(n(496)),a=i(n(17)),l=n(771),c=n(49);classd{constructor(e,t,n){this.name=e,this.isDefault=t,this.locations=n}}classu{constructor(e,t){this.path=e,this.name=t}}classpextendsl.Disposable{constructor(e,t){super(),this.locationHistory=e,this.wslManager=t,this._onDidChangeTreeData=this._register(news.EventEmitter),this.onDidChangeTreeData=this._onDidChangeTreeData.event,this._register(s.commands.registerCommand("openremotewsl.explorer.addDistro",(()=>(0,c.promptInstallNewWSLDistro)(t)))),this._register(s.commands.registerCommand("openremotewsl.explorer.refresh",(()=>this.refresh()))),this._register(s.commands.registerCommand("openremotewsl.explorer.emptyWindowInNewWindow",(e=>this.openRemoteWSLWindow(e,!1)))),this._register(s.commands.registerCommand("openremotewsl.explorer.emptyWindowInCurrentWindow",(e=>this.openRemoteWSLWindow(e,!0)))),this._register(s.commands.registerCommand("openremotewsl.explorer.reopenFolderInNewWindow",(e=>this.openRemoteWSLocationWindow(e,!1)))),this._register(s.commands.registerCommand("openremotewsl.explorer.reopenFolderInCurrentWindow",(e=>this.openRemoteWSLocationWindow(e,!0)))),this._register(s.commands.registerCommand("openremotewsl.explorer.deleteFolderHistoryItem",(e=>this.deleteDistroLocation(e)))),this._register(s.commands.registerCommand("openremotewsl.explorer.setDefaultDistro",(e=>this.setDefaultDistro(e)))),this._register(s.commands.registerCommand("openremotewsl.explorer.deleteDistro",(e=>this.deleteDistro(e))))}getTreeItem(e){if(einstanceofu){constt=a.posix.basename(e.path).replace(/\.code-workspace$/," (Workspace)"),n=news.TreeItem(t);returnn.description=a.posix.dirname(e.path),n.iconPath=news.ThemeIcon("folder"),n.contextValue="openremotewsl.explorer.folder",n}constt=news.TreeItem(e.name);returnt.description=e.isDefault?"default distro":void0,t.collapsibleState=e.locations.length?s.TreeItemCollapsibleState.Collapsed:s.TreeItemCollapsibleState.None,t.iconPath=news.ThemeIcon("vm"),t.contextValue="openremotewsl.explorer.distro",t}asyncgetChildren(e){returne?einstanceofd?e.locations.map((t=>newu(t,e.name))):[]:(awaitthis.wslManager.listDistros()).map((e=>newd(e.name,e.isDefault,this.locationHistory.getHistory(e.name))))}refresh(){this._onDidChangeTreeData.fire()}asyncdeleteDistroLocation(e){awaitthis.locationHistory.removeLocation(e.name,e.path),this.refresh()}asyncopenRemoteWSLWindow(e,t){(0,c.openRemoteWSLWindow)(e.name,t)}asyncopenRemoteWSLocationWindow(e,t){(0,c.openRemoteWSLLocationWindow)(e.name,e.path,t)}asyncsetDefaultDistro(e){await(0,c.setDefaultWSLDistro)(this.wslManager,e.name),this.refresh()}asyncdeleteDistro(e){await(0,c.deleteWSLDistro)(this.wslManager,e.name),this.refresh()}}t.DistroTreeDataProvider=p},112:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t},s=this&&this.__importDefault||function(e){returne&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deactivate=t.activate=void0;consta=i(n(496)),l=s(n(249)),c=n(618),d=n(49),u=n(679),p=n(879),h=n(114),m=n(400);t.activate=asyncfunction(e){if(!m.isWindows)return;constt=newl.default("Remote - WSL");e.subscriptions.push(t);constn=newh.WSLManager(t),r=newc.RemoteWSLResolver(n,t);e.subscriptions.push(a.workspace.registerRemoteAuthorityResolver(c.REMOTE_WSL_AUTHORITY,r)),e.subscriptions.push(r);consto=newp.RemoteLocationHistory(e),i=(0,p.getRemoteWorkspaceLocationData)();i&&awaito.addLocation(i[0],i[1]);consts=newu.DistroTreeDataProvider(o,n);e.subscriptions.push(a.window.createTreeView("wslTargets",{treeDataProvider:s})),e.subscriptions.push(s),e.subscriptions.push(a.commands.registerCommand("openremotewsl.connect",(()=>(0,d.promptOpenRemoteWSLWindow)(n,!0,!0)))),e.subscriptions.push(a.commands.registerCommand("openremotewsl.connectInNewWindow",(()=>(0,d.promptOpenRemoteWSLWindow)(n,!0,!1)))),e.subscriptions.push(a.commands.registerCommand("openremotewsl.connectUsingDistro",(()=>(0,d.promptOpenRemoteWSLWindow)(n,!1,!0)))),e.subscriptions.push(a.commands.registerCommand("openremotewsl.connectUsingDistroInNewWindow",(()=>(0,d.promptOpenRemoteWSLWindow)(n,!1,!1)))),e.subscriptions.push(a.commands.registerCommand("openremotewsl.showLog",(()=>t.show())))},t.deactivate=function(){}},879:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getRemoteWorkspaceLocationData=t.RemoteLocationHistory=void0;consts=i(n(496)),a=n(618);classl{constructor(e){this.context=e,this.remoteLocationHistory={},this.remoteLocationHistory=e.globalState.get(l.STORAGE_KEY)||{}}getHistory(e){returnthis.remoteLocationHistory[e]||[]}asyncaddLocation(e,t){letn=this.remoteLocationHistory[e]||[];n.includes(t)||(n.unshift(t),this.remoteLocationHistory[e]=n,awaitthis.context.globalState.update(l.STORAGE_KEY,this.remoteLocationHistory))}asyncremoveLocation(e,t){letn=this.remoteLocationHistory[e]||[];n=n.filter((e=>e!==t)),this.remoteLocationHistory[e]=n,awaitthis.context.globalState.update(l.STORAGE_KEY,this.remoteLocationHistory)}}t.RemoteLocationHistory=l,l.STORAGE_KEY="remoteLocationHistory_v0",t.getRemoteWorkspaceLocationData=function(){lete=s.workspace.workspaceFile;if(e&&"vscode-remote"===e.scheme&&e.authority.startsWith(a.REMOTE_WSL_AUTHORITY)&&e.path.endsWith(".code-workspace")){const[,t]=e.authority.split("+");return[t,e.path]}if(e=s.workspace.workspaceFolders?.[0].uri,e&&"vscode-remote"===e.scheme&&e.authority.startsWith(a.REMOTE_WSL_AUTHORITY)){const[,t]=e.authority.split("+");return[t,e.path]}}},487:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getVSCodeServerConfig=void0;consts=i(n(496)),a=i(n(147)),l=i(n(17));letc;t.getVSCodeServerConfig=asyncfunction(){conste=awaitasyncfunction(){if(!c){conste=awaita.promises.readFile(l.join(s.env.appRoot,"product.json"),"utf8");c=JSON.parse(e)}returnc}();return{version:s.version.replace("-insider",""),commit:e.commit,quality:e.quality,release:e.release,serverApplicationName:e.serverApplicationName,serverDataFolderName:e.serverDataFolderName,serverDownloadUrlTemplate:e.serverDownloadUrlTemplate}}},744:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.installCodeServer=t.ServerInstallError=void0;consts=i(n(113)),a=n(487);classlextendsError{constructor(e){super(e)}}t.ServerInstallError=l,t.installCodeServer=asyncfunction(e,t,n,r,o,i){constc=s.randomBytes(12).toString("hex"),d=await(0,a.getVSCodeServerConfig)(),u=function({id:e,quality:t,version:n,commit:r,release:o,extensionIds:i,envVariables:a,serverApplicationName:l,serverDataFolderName:c,serverDownloadUrlTemplate:d}){constu=i.map((e=>"--install-extension "+e)).join(" ");return`\n# Server installation script\n\nTMP_DIR="\${XDG_RUNTIME_DIR:-"/tmp"}"\n\nDISTRO_VERSION="${n}"\nDISTRO_COMMIT="${r}"\nDISTRO_QUALITY="${t}"\nDISTRO_VSCODIUM_RELEASE="${o??""}"\n\nSERVER_APP_NAME="${l}"\nSERVER_INITIAL_EXTENSIONS="${u}"\nSERVER_LISTEN_FLAG="--port=0"\nSERVER_DATA_DIR="$HOME/${c}"\nSERVER_DIR="$SERVER_DATA_DIR/bin/$DISTRO_COMMIT"\nSERVER_SCRIPT="$SERVER_DIR/bin/$SERVER_APP_NAME"\nSERVER_LOGFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.log"\nSERVER_PIDFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.pid"\nSERVER_TOKENFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.token"\nSERVER_OS=\nSERVER_ARCH=\nSERVER_CONNECTION_TOKEN=\nSERVER_DOWNLOAD_URL=\n\nLISTENING_ON=\nOS_RELEASE_ID=\nARCH=\nPLATFORM=\n\n# Mimic output from logs of remote-ssh extension\nprint_install_results_and_exit() {\n echo "${e}: start"\n echo "exitCode==$1=="\n echo "listeningOn==$LISTENING_ON=="\n echo "connectionToken==$SERVER_CONNECTION_TOKEN=="\n echo "logFile==$SERVER_LOGFILE=="\n echo "osReleaseId==$OS_RELEASE_ID=="\n echo "arch==$ARCH=="\n echo "platform==$PLATFORM=="\n echo "tmpDir==$TMP_DIR=="\n ${a.map((e=>`echo "${e}==$${e}=="`)).join("\n")}\n echo "${e}: end"\n exit 0\n}\n\n# Check if platform is supported\nPLATFORM="$(uname -s)"\ncase $PLATFORM in\n Linux)\n SERVER_OS="linux"\n ;;\n *)\n echo "Error platform not supported: $PLATFORM"\n print_install_results_and_exit 1\n ;;\nesac\n\n# Check machine architecture\nARCH="$(uname -m)"\ncase $ARCH in\n x86_64 | amd64)\n SERVER_ARCH="x64"\n ;;\n armv7l | armv8l)\n SERVER_ARCH="armhf"\n ;;\n arm64 | aarch64)\n SERVER_ARCH="arm64"\n ;;\n *)\n echo "Error architecture not supported: $ARCH"\n print_install_results_and_exit 1\n ;;\nesac\n\n# https://www.freedesktop.org/software/systemd/man/os-release.html\nOS_RELEASE_ID="debian"\nif [[ -z $OS_RELEASE_ID ]]; then\n OS_RELEASE_ID="debian"\n if [[ -z $OS_RELEASE_ID ]]; then\n OS_RELEASE_ID="unknown"\n fi\nfi\n\n# Create installation folder\nif [[ ! -d $SERVER_DIR ]]; then\n mkdir -p $SERVER_DIR\n if (( $? > 0 )); then\n echo "Error creating server install directory"\n print_install_results_and_exit 1\n fi\nfi\n\nSERVER_DOWNLOAD_URL="$(echo "${d.replace(/\$\{/g,"\\${")}" | sed "s/\\\${quality}/$DISTRO_QUALITY/g" | sed "s/\\\${version}/$DISTRO_VERSION/g" | sed "s/\\\${commit}/$DISTRO_COMMIT/g" | sed "s/\\\${os}/$SERVER_OS/g" | sed "s/\\\${arch}/$SERVER_ARCH/g" | sed "s/\\\${release}/$DISTRO_VSCODIUM_RELEASE/g")"\n\n# Check if server script is already installed\nif [[ ! -f $SERVER_SCRIPT ]]; then\n if [[ "$SERVER_OS" = "dragonfly" ]] || [[ "$SERVER_OS" = "freebsd" ]]; then\n echo "Error "$SERVER_OS" needs manual installation of remote extension host"\n print_install_results_and_exit 1\n fi\n\n pushd $SERVER_DIR > /dev/null\n\n if [[ ! -z $(which wget) ]]; then\n wget --tries=3 --timeout=10 --continue --no-verbose -O vscode-server.tar.gz $SERVER_DOWNLOAD_URL\n elif [[ ! -z $(which curl) ]]; then\n curl --retry 3 --connect-timeout 10 --location --show-error --silent --output vscode-server.tar.gz $SERVER_DOWNLOAD_URL\n else\n echo "Error no tool to download server binary"\n print_install_results_and_exit 1\n fi\n\n if (( $? > 0 )); then\n echo "Error downloading server from $SERVER_DOWNLOAD_URL"\n print_install_results_and_exit 1\n fi\n\n tar -xf vscode-server.tar.gz --strip-components 1\n if (( $? > 0 )); then\n echo "Error while extracting server contents"\n print_install_results_and_exit 1\n fi\n\n if [[ ! -f $SERVER_SCRIPT ]]; then\n echo "Error server contents are corrupted"\n print_install_results_and_exit 1\n fi\n\n rm -f vscode-server.tar.gz\n\n popd > /dev/null\nelse\n echo "Server script already installed in $SERVER_SCRIPT"\nfi\n\n# Try to find if server is already running\nif [[ -f $SERVER_PIDFILE ]]; then\n SERVER_PID="$(cat $SERVER_PIDFILE)"\n SERVER_RUNNING_PROCESS="$(ps -o pid,args -p $SERVER_PID | grep $SERVER_SCRIPT)"\nelse\n SERVER_RUNNING_PROCESS="$(ps -o pid,args -A | grep $SERVER_SCRIPT | grep -v grep)"\nfi\n\nif [[ -z $SERVER_RUNNING_PROCESS ]]; then\n if [[ -f $SERVER_LOGFILE ]]; then\n rm $SERVER_LOGFILE\n fi\n if [[ -f $SERVER_TOKENFILE ]]; then\n rm $SERVER_TOKENFILE\n fi\n\n touch $SERVER_TOKENFILE\n chmod 600 $SERVER_TOKENFILE\n SERVER_CONNECTION_TOKEN="${s.randomUUID()}"\n echo $SERVER_CONNECTION_TOKEN > $SERVER_TOKENFILE\n\n $SERVER_SCRIPT --start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --use-host-proxy --disable-websocket-compression --without-browser-env-var --enable-remote-auto-shutdown --accept-server-license-terms &> $SERVER_LOGFILE &\n echo $! > $SERVER_PIDFILE\nelse\n echo "Server script is already running $SERVER_SCRIPT"\nfi\n\nif [[ -f $SERVER_TOKENFILE ]]; then\n SERVER_CONNECTION_TOKEN="$(cat $SERVER_TOKENFILE)"\nelse\n echo "Error server token file not found $SERVER_TOKENFILE"\n print_install_results_and_exit 1\nfi\n\nif [[ -f $SERVER_LOGFILE ]]; then\n for i in {1..5}; do\n LISTENING_ON="$(cat $SERVER_LOGFILE | grep -E "Extension host agent listening on .+" | sed "s/Extension host agent listening on //")"\n if [[ -n $LISTENING_ON ]]; then\n break\n fi\n sleep 0.5\n done\n\n if [[ -z $LISTENING_ON ]]; then\n echo "Error server did not start sucessfully"\n print_install_results_and_exit 1\n fi\nelse\n echo "Error server log file not found $SERVER_LOGFILE"\n print_install_results_and_exit 1\nfi\n\n# Finish server setup and keep script running\nif [[ -z $SERVER_RUNNING_PROCESS ]]; then\n echo "${e}: start"\n echo "exitCode==0=="\n echo "listeningOn==$LISTENING_ON=="\n echo "connectionToken==$SERVER_CONNECTION_TOKEN=="\n echo "logFile==$SERVER_LOGFILE=="\n echo "osReleaseId==$OS_RELEASE_ID=="\n echo "arch==$ARCH=="\n echo "platform==$PLATFORM=="\n echo "tmpDir==$TMP_DIR=="\n ${a.map((e=>`echo "${e}==$${e}=="`)).join("\n")}\n echo "${e}: end"\n\n echo "${e}: Server installation script done"\n\n SERVER_PID="$(cat $SERVER_PIDFILE)"\n SERVER_RUNNING_PROCESS="$(ps -o pid,args -p $SERVER_PID | grep $SERVER_SCRIPT)"\n while [[ -n $SERVER_RUNNING_PROCESS ]]; do\n sleep 300;\n SERVER_RUNNING_PROCESS="$(ps -o pid,args -p $SERVER_PID | grep $SERVER_SCRIPT)"\n done\nelse\n print_install_results_and_exit 0\nfi\n`}({id:c,version:d.version,commit:d.commit,quality:d.quality,release:d.release,extensionIds:r,envVariables:o,serverApplicationName:d.serverApplicationName,serverDataFolderName:d.serverDataFolderName,serverDownloadUrlTemplate:n??d.serverDownloadUrlTemplate??"https://github.com/VSCodium/vscodium/releases/download/${version}.${release}/vscodium-reh-${os}-${arch}-${version}.${release}.tar.gz"}),p=awaite.exec("bash",["-c",`'${u.replace(/'/g,"'\\''")}'`],t),h=newRegExp(`${c}: Server installation script done`,"m"),m=awaitPromise.race([p.exitPromise.then((e=>({stdout:p.stdout,stderr:p.stderr,exitCode:e.exitCode}))),newPromise((e=>{p.onStdoutData((t=>{h.test(t.toString("utf8"))&&e({stdout:p.stdout,stderr:p.stderr,exitCode:0})}))}))]);m.exitCode&&i.trace("Server install command stderr:",m.stderr),i.trace("Server install command stdout:",m.stdout);constf=function(e,t){constn=`${t}: start`,r=`${t}: end`,o=e.indexOf(n);if(o<0)return;consti=e.indexOf(r,o+n.length);if(i<0)return;consts={},a=e.substring(o+n.length,i).split(/\r?\n/);for(consteofa){const[t,n]=e.split("==");s[t]=n}returns}(m.stdout,c);if(!f)thrownewl("Failed parsing install script output");const_=parseInt(f.exitCode,10);if(0!==_)thrownewl("Couldn't install vscode server on remote server, install script returned non-zero exit status");constE=parseInt(f.listeningOn,10),R=Object.fromEntries(Object.entries(f).filter((([e])=>o.includes(e))));return{exitCode:_,listeningOn:E,connectionToken:f.connectionToken,logFile:f.logFile,osReleaseId:f.osReleaseId,arch:f.arch,platform:f.platform,tmpDir:f.tmpDir,...R}}},114:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.WSLManager=void0;consts=i(n(81)),a=n(110),l="wsl.exe";t.WSLManager=class{constructor(e){this.logger=e}asynclistDistros(){conste=this._runWSLCommand(["--list","--verbose"],"utf16le"),{exitCode:t}=awaite.exitPromise,{stdout:n,stderr:r}=e;if(t)throwthis.logger.trace(`Command wsl listDistros exited with code ${t}`,n+"\n\n"+r),newError(`Command wsl listDistros exited with code ${t}`);consto=/(?<default>\*|\s)\s+(?<name>[\w\.-]+)\s+(?<state>[\w]+)\s+(?<version>\d)/,i=[];for(consteofn.split(/\r?\n/)){constt=e.match(o);t&&t.groups&&i.push({isDefault:"*"===t.groups.default,name:t.groups.name,state:t.groups.state,version:t.groups.version})}returni}asynclistOnlineDistros(){conste=this._runWSLCommand(["--list","--online"],"utf16le"),{exitCode:t}=awaite.exitPromise,{stdout:n,stderr:r}=e;if(t)throwthis.logger.trace(`Command wsl listOnlineDistros exited with code ${t}`,n+"\n\n"+r),newError(`Command wsl listOnlineDistros exited with code ${t}`);leto=n.split(/\r?\n/);consti=o.findIndex((e=>/\s*NAME\s+FRIENDLYNAME\s*/.test(e)));o=o.slice(i+1);consts=/(?<name>[\w\.-]+)\s+(?<friendlyName>\w.+\w)/,a=[];for(consteofo){constt=e.match(s);t&&t.groups&&a.push({name:t.groups.name,friendlyName:t.groups.friendlyName})}returna}asyncsetDefaultDistro(e){constt=this._runWSLCommand(["--set-default",e],"utf16le"),{exitCode:n}=awaitt.exitPromise,{stdout:r,stderr:o}=t;if(n)throwthis.logger.trace(`Command wsl setDefaultDistro exited with code ${n}`,r+"\n\n"+o),newError(`Command wsl setDefaultDistro exited with code ${n}`)}asyncdeleteDistro(e){constt=this._runWSLCommand(["--unregister",e],"utf16le"),{exitCode:n}=awaitt.exitPromise,{stdout:r,stderr:o}=t;if(n)throwthis.logger.trace(`Command wsl deleteDistro exited with code ${n}`,r+"\n\n"+o),newError(`Command wsl deleteDistro exited with code ${n}`)}asyncexec(e,t,n){returnthis._runWSLCommand(["--distribution",n,"--",e,...t],"utf8")}_runWSLCommand(e,t){this.logger.trace(`Running WSL command: ${l}${e.join(" ")}`);constn=s.spawn(l,e,{windowsHide:!0,windowsVerbatimArguments:!0}),r=newa.EventEmitter,o=[],i=newa.EventEmitter,c=[];returnn.stdout.on("data",(e=>{o.push(e),r.fire(e)})),n.stderr.on("data",(e=>{c.push(e),i.fire(e)})),{getstdout(){returnBuffer.concat(o).toString(t)},getstderr(){returnBuffer.concat(c).toString(t)},getonStdoutData(){returnr.event},getonStderrData(){returni.event},exitPromise:newPromise(((t,r)=>{n.on("error",(t=>{this.logger.error(`Error running WSL command: ${l}${e.join(" ")}`,t),r(t)})),n.on("exit",((e,n)=>{t({exitCode:e??0})}))}))}}}},574:function(e,t,n){varr=this&&this.__createBinding||(Object.create?function(e,t,n,r){void0===r&&(r=n);varo=Object.getOwnPropertyDescriptor(t,n);o&&!("get"ino?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){returnt[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)returne;vart={};if(null!=e)for(varnine)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);returno(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});consts=i(n(496));classa{getTerminal(){returns.window.terminals.find((e=>e.name===a.NAME))||s.window.createTerminal(a.NAME)}runCommand(e){constt=this.getTerminal();t.show(!1),t.sendText(e,!0)}}a.NAME="WSL",t.default=newa},496:e=>{e.exports=require("vscode")},81:e=>{e.exports=require("child_process")},113:e=>{e.exports=require("crypto")},147:e=>{e.exports=require("fs")},17:e=>{e.exports=require("path")}},t={},n=functionn(r){varo=t[r];if(void0!==o)returno.exports;vari=t[r]={exports:{}};returne[r].call(i.exports,i,i.exports,n),i.exports}(112);module.exports=n})();
You have to replace debian with whatever distribution you try to target.
The text was updated successfully, but these errors were encountered:
Not related to #2 and #4.
Using Windows 10, trying to connect Debian on WSL2.
Connecting to WSL is broken, as the installation script is passed via
wsl.exe ...cli-options... -- bash -c '.....script-content...'
, wherescript-content
contains single quotes. Obviously, the first single quote inside the script will terminate the one launched in the shell running thatwsl
command, leading to an unrecoverable error.It especially does not make sense, as those single quotes can be replaced with double quotes, without causing issues, as far as I have checked.
Workaround
I hotfix patched the
extension.js
@"C:\Users\USERNAME\.vscode-oss\extensions\jeanp413.open-remote-wsl-0.0.4-universal\out\extension.js"
with the following content.You have to replace
debian
with whatever distribution you try to target.The text was updated successfully, but these errors were encountered: