Open GopherJ opened 4 years ago
I tried sccache -z
sccache --stop-server
then sccache --start-server
, and this problem has been fixed but still want to know how to avoid this issue? any idea?
@GopherJ Thanks for the workaround! I had the same issue, and your fix worked.
There is also #428, where it was suggested to improve the error message.
@GopherJ @vks do y'all happen to be using neovim/coc.nvim/coc-rust-analyzer?
I ask because I've had this issue recently, and I did some digging. In my situation it happens to be because coc recently started passing down a neovim-specific $TMPDIR to rust-analyzer, so if sccache gets started via coc-rust-analyzer and persists past the neovim temp dir, future invocations against that sccache server will fail.
I verified this by stopping sccache, opening up a source file in vim, and taking a look at the $TMPDIR for the sccache process that got started. (elided to remove some irrelevant details):
~/workspaces/crates/sr/src $ sccache --stop-server
Stopping sccache server...
<elided...>
~/workspaces/crates/sr/src $ vim handlers.rs
~/workspaces/crates/sr/src $ ps eww -o command $(pgrep sccache) | tr ' ' '\n'|grep TMPDIR
TMPDIR=/var/folders/k7/73sn0kxs6djcp1gmnz5szj9w0000gn/T/nvimRiPj29
~/workspaces/crates/sr/src $ cargo clean && cargo build
Compiling libc v0.2.77
<...>
Compiling hashbrown v0.9.0
sccache: encountered fatal error
sccache: error : Failed to create temp dir
sccache: cause: Failed to create temp dir
sccache: cause: No such file or directory (os error 2)
error: could not compile `cfg-if`.
Caused by:
process didn't exit successfully: `sccache rustc --crate-name cfg_if --edition=2018 /Users/danny/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.10/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=97c7538b5aa45476 -C extra-filename=-97c7538b5aa45476 --out-dir /Users/danny/workspaces/crates/target/debug/deps -L dependency=/Users/danny/workspaces/crates/target/debug/deps --cap-lints allow -Ctarget-cpu=native -Ccodegen-units=12` (exit code: 254)
warning: build failed, waiting for other jobs to finish...
sccache: encountered fatal error
sccache: encountered fatal error
sccache: error : Failed to create temp dir
sccache: error : Failed to create temp dir
sccache: cause: Failed to create temp dir
sccache: cause: Failed to create temp dir
sccache: cause: No such file or directory (os error 2)
sccache: cause: No such file or directory (os error 2)
<...elided a bunch of these errors...>
sccache: error : Failed to create temp dir
sccache: cause: Failed to create temp dir
sccache: cause: No such file or directory (os error 2)
error: build failed
Note the nvimRiPj29
at the end of the $TMP_DIR path.
The coc change is recent, so it doesn't line up quite with #428 but the root cause could be something similar.
I tried adding sccache --start-server &> /dev/null
to my .zshrc to make sure I always have a non-nvim-started sccache, but it looks like the sccache server process can still die, as i've observed sccache instances with the bad $TMPDIR a few times.
So the restarting-sccache workaround works, but I'm not sure what a more lasting fix to this might be. If the $TMPDIR that sccache is passed gets deleted, I'm not sure what sccache ought to do. Potentially, I can follow up with the coc.nvim maintainer.
@cthulhua Yes, I think this is it!
Oh, that's interesting! Good catch! I wonder if the sccache server ought to be more judicious about choosing its temp dir? Honoring the environment variable is probably the right thing to do in the general case, but the way that sccache spawns a daemon by way of the compiler wrapper is a bit of an edge case.
Yes I'm using coc.nvim + coc-rust-analyzer
I tried adding
sccache --start-server &> /dev/null
to my .zshrc to make sure I always have a non-nvim-started sccache, but it looks like the sccache server process can still die, as i've observed sccache instances with the bad $TMPDIR a few times.
You should be able to do SCCACHE_IDLE_TIMEOUT=0 sccache --start-server &> /dev/null
to prevent the server from exiting.
Awesome. I'm not sure what needs to happen per @luser's comment, but I'm in good shape now with this workaround.
I'm glad there's a workaround and all, but it's definitely a little frustrating that this can be messed up system-wide if a vim session with Coc or anything else that uses the daemon can mess this up. Even if this is "fixed" on the Coc side, it's totally possible for something else to break it.
sccache is a great piece of software, but this is frustrating nonetheless.
Any news on this pls, it's really annoying:)
I ran into this after rustup update
. Killing the server worked, but I'm not setting a custom TMPDIR
anywhere.
Same issue here. I hope this will be fixed.
@drahnr Gentoo is hitting this issue as described in the PR to update to 0.3.0
.
https://github.com/gentoo/gentoo/pull/27478
sccache-0.3.0/target/release/build/syn-1f024f804478b580 -L dependency=/var/tmp/portage/dev-util/sccache-0.3.0/work/sccache-0.3.0/target/release/deps --cap-lints allow`
sccache: encountered fatal error
sccache: error: Failed to create temp dir
sccache: caused by: Failed to create temp dir
sccache: caused by: No such file or directory (os error 2) at path "/var/tmp/portage/dev-util/cargo-ebuild-0.5.2/temp/sccacheaxtW5u"
error: could not compile `unicode-xid`
This happens when it wants to use the temp directory from the previous build instead of the current one.
Is there anything that can be done to resolve this in sccache soon?