Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit a5dd315

Browse files
committed
Remove the RUST_SRC_PATH environment variable
If the RUST_SRC env var was already set, we should keep that value and not change it. If it was not set, rust-analyzer is very well capable of finding that path on its own. Fixes #184
1 parent 035656b commit a5dd315

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

lib/index.js

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,6 @@ function shouldIgnoreProjectPath(projectPath) {
142142
.some(path => path === projectPath.trim().replace(/[/\\]*$/, ''))
143143
}
144144

145-
/**
146-
* @param {string} [toolchain]
147-
* @param {string} [cwd]
148-
* @return {Promise<string>} `rustc --print sysroot` stdout
149-
*/
150-
async function rustcSysroot(toolchain, cwd) {
151-
try {
152-
let { stdout } = await rustupRun(toolchain, "rustc --print sysroot", { cwd })
153-
return stdout.trim()
154-
} catch (e) {
155-
// make an attempt to use system rustc
156-
try {
157-
let { stdout } = await exec(`rustc --print sysroot`, { cwd })
158-
return stdout.trim()
159-
} catch (sys_e) {
160-
throw e
161-
}
162-
}
163-
}
164-
165145
/** @return {string} environment variable path */
166146
let envPath = () => {
167147
// Make sure the cargo directory is in PATH
@@ -176,7 +156,7 @@ let envPath = () => {
176156
* @param {string} [cwd]
177157
* @return {Promise<object>} environment vars
178158
*/
179-
async function serverEnv(toolchain, cwd) {
159+
function serverEnv() {
180160
const env = process.env
181161
env.PATH = envPath()
182162
env.RUST_BACKTRACE = env.RUST_BACKTRACE || "1"
@@ -185,12 +165,6 @@ async function serverEnv(toolchain, cwd) {
185165
// env.RUST_LOG = 'info'
186166
// }
187167

188-
try {
189-
let sysroot = await rustcSysroot(toolchain, cwd)
190-
env.RUST_SRC_PATH = path.join(sysroot, "/lib/rustlib/src/rust/src/")
191-
} catch (e) {
192-
console.warn("Failed to find sysroot: " + e)
193-
}
194168
return env
195169
}
196170

@@ -553,7 +527,7 @@ class RustLanguageClient extends AutoLanguageClient {
553527
clearIdeRustNotifications("ide-rust.langServerCommand")
554528

555529
return logSuspiciousStdout(cp.spawn(languageServerCmd, {
556-
env: await serverEnv(configToolchain()),
530+
env: serverEnv(),
557531
shell: true,
558532
cwd: projectPath
559533
}))

0 commit comments

Comments
 (0)