Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit f810a27

Browse files
authored
Merge pull request #782 from rust-lang/prune-use-wsl
Remove useWsl related logic
2 parents 9b2225a + d338cbd commit f810a27

File tree

9 files changed

+39
-231
lines changed

9 files changed

+39
-231
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
### Unreleased
22

3+
* Remove deprecated `rust-client.useWsl` setting (use the official
4+
[Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension instead)
5+
36
### 0.7.4 - 2020-04-27
47

58
* Add a Start/Stop the RLS command

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@
169169
"description": "Path to rustup executable. Ignored if rustup is disabled.",
170170
"scope": "machine"
171171
},
172-
"rust-client.useWSL": {
173-
"type": "boolean",
174-
"default": false,
175-
"description": "When set to true, RLS is started within Windows Subsystem for Linux."
176-
},
177172
"rust-client.rlsPath": {
178173
"type": [
179174
"string",

src/configuration.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { window, workspace, WorkspaceConfiguration } from 'vscode';
1+
import { workspace, WorkspaceConfiguration } from 'vscode';
22
import { RevealOutputChannelOn } from 'vscode-languageclient';
33

44
import { getActiveChannel, RustupConfig } from './rustup';
@@ -26,14 +26,6 @@ export class RLSConfiguration {
2626
private constructor(configuration: WorkspaceConfiguration, wsPath: string) {
2727
this.configuration = configuration;
2828
this.wsPath = wsPath;
29-
30-
if (this.configuration.get<boolean>('rust-client.useWSL')) {
31-
window.showWarningMessage(
32-
'Option `rust-client.useWsl` is enabled for this workspace, which is DEPRECATED.\
33-
For a complete and first-class WSL support try Remote - WSL extension \
34-
extension (https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl)',
35-
);
36-
}
3729
}
3830

3931
public static loadFromWorkspace(wsPath: string): RLSConfiguration {
@@ -79,10 +71,6 @@ export class RLSConfiguration {
7971
return this.configuration.get('rust-client.rustupPath', 'rustup');
8072
}
8173

82-
public get useWSL(): boolean {
83-
return this.configuration.get<boolean>('rust-client.useWSL', false);
84-
}
85-
8674
public get logToFile(): boolean {
8775
return this.configuration.get<boolean>('rust-client.logToFile', false);
8876
}
@@ -130,7 +118,6 @@ export class RLSConfiguration {
130118
return {
131119
channel: ignoreChannel ? '' : this.channel,
132120
path: this.rustupPath,
133-
useWSL: this.useWSL,
134121
};
135122
}
136123
}

src/extension.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as child_process from 'child_process';
22
import * as fs from 'fs';
33
import * as path from 'path';
4+
import * as util from 'util';
45
import {
56
commands,
67
ConfigurationTarget,
@@ -27,10 +28,10 @@ import { SignatureHelpProvider } from './providers/signatureHelpProvider';
2728
import { checkForRls, ensureToolchain, rustupUpdate } from './rustup';
2829
import { startSpinner, stopSpinner } from './spinner';
2930
import { activateTaskProvider, Execution, runRlsCommand } from './tasks';
30-
import { withWsl } from './utils/child_process';
3131
import { Observable } from './utils/observable';
3232
import { nearestParentWorkspace } from './utils/workspace';
33-
import { uriWindowsToWsl, uriWslToWindows } from './utils/wslpath';
33+
34+
const exec = util.promisify(child_process.exec);
3435

3536
/**
3637
* Parameter type to `window/progress` request as issued by the RLS.
@@ -233,23 +234,6 @@ class ClientWorkspace {
233234
workspaceFolder: this.folder,
234235
};
235236

236-
// Changes paths between Windows and Windows Subsystem for Linux
237-
if (this.config.useWSL) {
238-
clientOptions.uriConverters = {
239-
code2Protocol: (uri: Uri) => {
240-
const res = Uri.file(uriWindowsToWsl(uri.fsPath)).toString();
241-
console.log(`code2Protocol for path ${uri.fsPath} -> ${res}`);
242-
return res;
243-
},
244-
protocol2Code: (wslUri: string) => {
245-
const urlDecodedPath = Uri.parse(wslUri).path;
246-
const winPath = Uri.file(uriWslToWindows(urlDecodedPath));
247-
console.log(`protocol2Code for path ${wslUri} -> ${winPath.fsPath}`);
248-
return winPath;
249-
},
250-
};
251-
}
252-
253237
// Create the language client and start the client.
254238
this.lc = new LanguageClient(
255239
'rust-client',
@@ -330,12 +314,10 @@ class ClientWorkspace {
330314
}
331315

332316
private async getSysroot(env: typeof process.env): Promise<string> {
333-
const wslWrapper = withWsl(this.config.useWSL);
334-
335317
const rustcPrintSysroot = () =>
336318
this.config.rustupDisabled
337-
? wslWrapper.exec('rustc --print sysroot', { env })
338-
: wslWrapper.exec(
319+
? exec('rustc --print sysroot', { env })
320+
: exec(
339321
`${this.config.rustupPath} run ${this.config.channel} rustc --print sysroot`,
340322
{ env },
341323
);
@@ -424,7 +406,7 @@ class ClientWorkspace {
424406
}
425407

426408
const env = await makeRlsEnv();
427-
childProcess = withWsl(config.useWSL).spawn(
409+
childProcess = child_process.spawn(
428410
config.path,
429411
['run', config.channel, rlsPath],
430412
{ env, cwd, shell: true },

src/rustup.ts

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
* @file This module handles running the RLS via rustup, including checking that
33
* rustup is installed and installing any required components/toolchains.
44
*/
5+
import * as child_process from 'child_process';
6+
import * as util from 'util';
57
import { window } from 'vscode';
68

79
import { startSpinner, stopSpinner } from './spinner';
810
import { runTaskCommand } from './tasks';
9-
import { withWsl } from './utils/child_process';
11+
12+
const exec = util.promisify(child_process.exec);
1013

1114
const REQUIRED_COMPONENTS = ['rust-analysis', 'rust-src', 'rls'];
1215

@@ -17,16 +20,13 @@ function isInstalledRegex(componentName: string): RegExp {
1720
export interface RustupConfig {
1821
channel: string;
1922
path: string;
20-
useWSL: boolean;
2123
}
2224

2325
export async function rustupUpdate(config: RustupConfig) {
2426
startSpinner('Updating…');
2527

2628
try {
27-
const { stdout } = await withWsl(config.useWSL).exec(
28-
`${config.path} update`,
29-
);
29+
const { stdout } = await exec(`${config.path} update`);
3030

3131
// This test is imperfect because if the user has multiple toolchains installed, they
3232
// might have one updated and one unchanged. But I don't want to go too far down the
@@ -83,20 +83,12 @@ export async function checkForRls(config: RustupConfig) {
8383

8484
async function hasToolchain(config: RustupConfig): Promise<boolean> {
8585
try {
86-
const { stdout } = await withWsl(config.useWSL).exec(
87-
`${config.path} toolchain list`,
88-
);
86+
const { stdout } = await exec(`${config.path} toolchain list`);
8987
return stdout.includes(config.channel);
9088
} catch (e) {
9189
console.log(e);
92-
const rustupFoundButNotInWSLMode =
93-
config.useWSL && (await hasRustup({ useWSL: false, ...config }));
94-
9590
window.showErrorMessage(
96-
rustupFoundButNotInWSLMode
97-
? `Rustup is installed but can't be found under WSL. Ensure that
98-
invoking \`wsl rustup\` works correctly.`
99-
: 'Rustup not available. Install from https://www.rustup.rs/',
91+
'Rustup not available. Install from https://www.rustup.rs/',
10092
);
10193
throw e;
10294
}
@@ -105,11 +97,8 @@ async function hasToolchain(config: RustupConfig): Promise<boolean> {
10597
async function tryToInstallToolchain(config: RustupConfig) {
10698
startSpinner('Installing toolchain…');
10799
try {
108-
const { command, args } = withWsl(config.useWSL).modifyArgs(config.path, [
109-
'toolchain',
110-
'install',
111-
config.channel,
112-
]);
100+
const command = config.path;
101+
const args = ['toolchain', 'install', config.channel];
113102
await runTaskCommand({ command, args }, 'Installing toolchain…');
114103
if (!(await hasToolchain(config))) {
115104
throw new Error();
@@ -128,14 +117,14 @@ async function tryToInstallToolchain(config: RustupConfig) {
128117
* valid listed component name.
129118
*/
130119
async function listComponents(config: RustupConfig): Promise<string[]> {
131-
return withWsl(config.useWSL)
132-
.exec(`${config.path} component list --toolchain ${config.channel}`)
133-
.then(({ stdout }) =>
134-
stdout
135-
.toString()
136-
.replace('\r', '')
137-
.split('\n'),
138-
);
120+
return exec(
121+
`${config.path} component list --toolchain ${config.channel}`,
122+
).then(({ stdout }) =>
123+
stdout
124+
.toString()
125+
.replace('\r', '')
126+
.split('\n'),
127+
);
139128
}
140129

141130
async function hasRlsComponents(config: RustupConfig): Promise<boolean> {
@@ -158,13 +147,14 @@ async function installRlsComponents(config: RustupConfig) {
158147

159148
for (const component of REQUIRED_COMPONENTS) {
160149
try {
161-
const { command, args } = withWsl(config.useWSL).modifyArgs(config.path, [
150+
const command = config.path;
151+
const args = [
162152
'component',
163153
'add',
164154
component,
165155
'--toolchain',
166156
config.channel,
167-
]);
157+
];
168158
await runTaskCommand({ command, args }, `Installing \`${component}\``);
169159

170160
const isInstalled = isInstalledRegex(component);
@@ -226,7 +216,7 @@ export function parseActiveToolchain(rustupOutput: string): string {
226216
export async function getVersion(config: RustupConfig): Promise<string> {
227217
const versionRegex = /rustup ([0-9]+\.[0-9]+\.[0-9]+)/;
228218

229-
const output = await withWsl(config.useWSL).exec(`${config.path} --version`);
219+
const output = await exec(`${config.path} --version`);
230220
const versionMatch = output.stdout.toString().match(versionRegex);
231221
if (versionMatch && versionMatch.length >= 2) {
232222
return versionMatch[1];
@@ -256,8 +246,10 @@ export function getActiveChannel(wsPath: string, config: RustupConfig): string {
256246
let activeChannel;
257247
try {
258248
// `rustup show active-toolchain` is available since rustup 1.12.0
259-
activeChannel = withWsl(config.useWSL)
260-
.execSync(`${config.path} show active-toolchain`, { cwd: wsPath })
249+
activeChannel = child_process
250+
.execSync(`${config.path} show active-toolchain`, {
251+
cwd: wsPath,
252+
})
261253
.toString()
262254
.trim();
263255
// Since rustup 1.17.0 if the active toolchain is the default, we're told
@@ -267,8 +259,10 @@ export function getActiveChannel(wsPath: string, config: RustupConfig): string {
267259
activeChannel = activeChannel.replace(/ \(.*\)$/, '');
268260
} catch (e) {
269261
// Possibly an old rustup version, so try rustup show
270-
const showOutput = withWsl(config.useWSL)
271-
.execSync(`${config.path} show`, { cwd: wsPath })
262+
const showOutput = child_process
263+
.execSync(`${config.path} show`, {
264+
cwd: wsPath,
265+
})
272266
.toString();
273267
activeChannel = parseActiveToolchain(showOutput);
274268
}

src/utils/child_process.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/utils/wslpath.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)