Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sccache: error : Failed to create temp dir #837

Open
GopherJ opened this issue Aug 26, 2020 · 13 comments
Open

sccache: error : Failed to create temp dir #837

GopherJ opened this issue Aug 26, 2020 · 13 comments

Comments

@GopherJ
Copy link

GopherJ commented Aug 26, 2020

sccache: encountered fatal error
sccache: encountered fatal error
sccache: encountered fatal error
sccache: error : Failed to create temp dir
sccache:  cause: Failed to create temp dir
sccache: error : 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)
error: could not compile `unicode-xid`.

Caused by:
  process didn't exit successfully: `/home/cheng/.cargo/bin/sccache rustc --crate-name unicode_xid /home/cheng/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-xid-0.2.1/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 --cfg 'feature="default"' -C metadata=b13daac5d45350a3 -C extra-filename=-b13daac5d45350a3 --out-dir /home/cheng/Projects/Rust/examples/target/debug/deps -L dependency=/home/cheng/Projects/Rust/examples/target/debug/deps --cap-lints allow` (exit code: 254)
warning: build failed, waiting for other jobs to finish...
sccache: error : Failed to create temp dir
sccache:  cause: Failed to create temp dir
sccache:  cause: No such file or directory (os error 2)
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)
sccache: encountered fatal error
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)
sccache: error : Failed to create temp dir
sccache:  cause: Failed to create temp dir
sccache:  cause: No such file or directory (os error 2)
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)
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: build failed

@GopherJ
Copy link
Author

GopherJ commented Aug 26, 2020

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?

@vks
Copy link

vks commented Aug 27, 2020

@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.

@cthulhua
Copy link

@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.

@vks
Copy link

vks commented Sep 15, 2020

@cthulhua Yes, I think this is it!

@luser
Copy link
Contributor

luser commented Sep 15, 2020

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.

@GopherJ
Copy link
Author

GopherJ commented Sep 15, 2020

Yes I'm using coc.nvim + coc-rust-analyzer

@froydnj
Copy link
Contributor

froydnj commented Sep 15, 2020

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.

@cthulhua
Copy link

Awesome. I'm not sure what needs to happen per @luser's comment, but I'm in good shape now with this workaround.

@DarrienG
Copy link

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.

@GopherJ
Copy link
Author

GopherJ commented Oct 24, 2020

Any news on this pls, it's really annoying:)

@lnicola
Copy link

lnicola commented Dec 30, 2020

I ran into this after rustup update. Killing the server worked, but I'm not setting a custom TMPDIR anywhere.

@Kogia-sima
Copy link

Same issue here. I hope this will be fixed.

@orbea
Copy link

orbea commented Sep 26, 2022

@drahnr Gentoo is hitting this issue as described in the PR to update to 0.3.0.

gentoo/gentoo#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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants