Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Workaround #703 to prevent obscure failures due to sccache. #1177

Merged
merged 1 commit into from
Dec 10, 2018
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
15 changes: 15 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
)]
extern "C" {}

use log::warn;
use env_logger;
use rustc_tools_util::*;

Expand All @@ -60,6 +61,7 @@ pub mod server;
mod test;

const RUSTC_SHIM_ENV_VAR_NAME: &str = "RLS_RUSTC_SHIM";
const RUSTC_WRAPPER_ENV_VAR: &str = "RUSTC_WRAPPER";

type Span = rls_span::Span<rls_span::ZeroIndexed>;

Expand All @@ -73,6 +75,19 @@ pub fn main() {
fn main_inner() -> i32 {
env_logger::init();

// [workaround]
// Currently sccache breaks RLS with obscure error messages.
// Until it's actually fixed disable the wrapper completely
// in the current process tree.
//
// See https://github.com/rust-lang/rls/issues/703
// and https://github.com/mozilla/sccache/issues/303
if env::var_os(RUSTC_WRAPPER_ENV_VAR).is_some() {
warn!("The {} environment variable is incompatible with RLS, \
removing it from the process environment", RUSTC_WRAPPER_ENV_VAR);
env::remove_var(RUSTC_WRAPPER_ENV_VAR);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this condition correct? It says only time we want to keep this env-var is when it is sccache?

Reading the #703 I'd have expected something like:

if env::var(RUSTC_WRAPPER_ENV_VAR).map(|v| v.ends_with("sccache")) == Ok(true) {
    env::remove_var(RUSTC_WRAPPER_ENV_VAR);
}

Or, if it's the case that RLS does not support RUSTC_WRAPPER why not simply:

if env::var_os(RUSTC_WRAPPER_ENV_VAR).is_some() {
    env::remove_var(RUSTC_WRAPPER_ENV_VAR);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dear, thanks, of course it should have been == and not !=. Looking at #703 once again I think that getting rid of the variable altogether is a better idea.

}

if env::var(RUSTC_SHIM_ENV_VAR_NAME)
.map(|v| v != "0")
.unwrap_or(false)
Expand Down