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

Commit 3a1610a

Browse files
committed
Workaround #703 to prevent obscure failures due to sccache.
1 parent bfa1371 commit 3a1610a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main.rs

+15
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
)]
3838
extern "C" {}
3939

40+
use log::warn;
4041
use env_logger;
4142
use rustc_tools_util::*;
4243

@@ -60,6 +61,7 @@ pub mod server;
6061
mod test;
6162

6263
const RUSTC_SHIM_ENV_VAR_NAME: &str = "RLS_RUSTC_SHIM";
64+
const RUSTC_WRAPPER_ENV_VAR: &str = "RUSTC_WRAPPER";
6365

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

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

78+
// [workaround]
79+
// Currently sccache breaks RLS with obscure error messages.
80+
// Until it's actually fixed disable the wrapper completely
81+
// in the current process tree.
82+
//
83+
// See https://github.com/rust-lang/rls/issues/703
84+
// and https://github.com/mozilla/sccache/issues/303
85+
if env::var_os(RUSTC_WRAPPER_ENV_VAR).is_some() {
86+
warn!("The {} environment variable is incompatible with RLS, \
87+
removing it from the environment", RUSTC_WRAPPER_ENV_VAR);
88+
env::remove_var(RUSTC_WRAPPER_ENV_VAR);
89+
}
90+
7691
if env::var(RUSTC_SHIM_ENV_VAR_NAME)
7792
.map(|v| v != "0")
7893
.unwrap_or(false)

0 commit comments

Comments
 (0)