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

Remove the RUST_SRC_PATH environment variable #185

Merged
merged 5 commits into from
Jul 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 2 additions & 30 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,6 @@ function shouldIgnoreProjectPath(projectPath) {
.some(path => path === projectPath.trim().replace(/[/\\]*$/, ''))
}

/**
* @param {string} [toolchain]
* @param {string} [cwd]
* @return {Promise<string>} `rustc --print sysroot` stdout
*/
async function rustcSysroot(toolchain, cwd) {
try {
let { stdout } = await rustupRun(toolchain, "rustc --print sysroot", { cwd })
return stdout.trim()
} catch (e) {
// make an attempt to use system rustc
try {
let { stdout } = await exec(`rustc --print sysroot`, { cwd })
return stdout.trim()
} catch (sys_e) {
throw e
}
}
}

/** @return {string} environment variable path */
let envPath = () => {
// Make sure the cargo directory is in PATH
Expand All @@ -172,11 +152,9 @@ let envPath = () => {
}

/**
* @param {string} [toolchain]
* @param {string} [cwd]
* @return {Promise<object>} environment vars
*/
async function serverEnv(toolchain, cwd) {
function serverEnv() {
const env = process.env
env.PATH = envPath()
env.RUST_BACKTRACE = env.RUST_BACKTRACE || "1"
Expand All @@ -185,12 +163,6 @@ async function serverEnv(toolchain, cwd) {
// env.RUST_LOG = 'info'
// }

try {
let sysroot = await rustcSysroot(toolchain, cwd)
env.RUST_SRC_PATH = path.join(sysroot, "/lib/rustlib/src/rust/src/")
} catch (e) {
console.warn("Failed to find sysroot: " + e)
}
return env
}

Expand Down Expand Up @@ -546,7 +518,7 @@ class RustLanguageClient extends AutoLanguageClient {
clearIdeRustNotifications("ide-rust.langServerCommand")

return logSuspiciousStdout(cp.spawn(languageServerCmd, {
env: await serverEnv(configToolchain()),
env: serverEnv(),
shell: true,
cwd: projectPath
}))
Expand Down