-
Notifications
You must be signed in to change notification settings - Fork 623
Description
This morning I encountered a relatively baffling error message:
# sccache $HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc -vV
sccache: error: path must be shorter than SUN_LEN
From the looks of it, what's happening is that I was 5 nix-shells deep and my $TMPDIR got quite long:
/tmp/nix-shell-1869814-3862691756/nix-shell-1870212-64442319/nix-shell-1870771-4262528264/nix-shell-1879125-3109976699/nix-shell.xlRp88
Initially I thought this was affecting specifically the client-server socket, overriding that path would fail the same way:
# env SCCACHE_SERVER_UDS=$HOME/.cache/sccache/sock sccache $HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc -vV
sccache: error: path must be shorter than SUN_LEN
My current theory is that its the following part:
Lines 94 to 110 in de9895c
| let socket_path = tempdir.path().join("sock"); | |
| let runtime = Runtime::new()?; | |
| let exe_path = env::current_exe()?; | |
| let workdir = exe_path.parent().expect("executable path has no parent?!"); | |
| // Spawn a blocking task to bind the Unix socket. Note that the socket | |
| // must be bound before spawning `_child` below to avoid a race between | |
| // the parent binding the socket and the child connecting to it. | |
| let listener = { | |
| let _guard = runtime.enter(); | |
| tokio::net::UnixListener::bind(&socket_path)? | |
| }; | |
| let _child = process::Command::new(&exe_path) | |
| .current_dir(workdir) | |
| .env("SCCACHE_START_SERVER", "1") | |
| .env("SCCACHE_STARTUP_NOTIFY", &socket_path) |
which probably could be made more resilient by inheriting a pipe file descriptor.
Recovering from this was not as straightforward as exiting the nix shells and fixing up TMPDIR – there seems to have been some sort of a leftover in target/ that kept sccache try the long path until I deleted target/. Only then I was able to successfully invoke cargo/rustc with the RUSTC_WRAPPER=sccache set.