Rust: Warning Message of `cargo build` when using vscode-remote of wsl

Created on 21 Jun 2019  Â·  12Comments  Â·  Source: rust-lang/rust

I'm learning Rust with Visual Studio Code and WSL, and I have installed the Rust(rls) plugin on vscode. But when I compile my project with cargo build command, warning message occured as follows:

hello_cargo git:(master) ✗ cargo build --verbose
   Compiling hello_cargo v0.1.0 (/home/admiraldollbug/rustTest/hello_cargo)
     Running rustc --edition=2018 --crate-name hello_cargo src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=2773c05304224b24 -C extra-filename=-2773c05304224b24 --out-dir /home/admiraldollbug/rustTest/hello_cargo/target/debug/deps -C incremental=/home/admiraldollbug/rustTest/hello_cargo/target/debug/incremental -L dependency=/home/admiraldollbug/rustTest/hello_cargo/target/debug/deps`
warning: Error finalizing incremental compilation session directory `/home/admiraldollbug/rustTest/hello_cargo/target/debug/incremental/hello_cargo-3fff4itd3xshd/s-fddic00q5j-2o52yu-working`: Permission denied (os error 13)

    Finished dev [unoptimized + debuginfo] target(s) in 0.97s

However, as you can see, the build process completed normally and meanwhile the cargo run command runs the program correctly. Another thing is that when i compile with the --release param, the warning doesnt emerge.
I'm wondering what the warning message means and what effect it would brings. I can't find the detail of this message on Google or on official doc, so I opened this issue.

O-linux

Most helpful comment

This issue is happening for me even without any vs-code instance running.

warning: Error finalizing incremental compilation session directory `/home/95th/btrs/target/debug/incremental/btrs-311gr3ac8npws/s-fjgujplfts-i503kt-working`: Permission denied (os error 13)

delete the target folder, exclude future target folders from being watched with files.watcherExclude (e.g. "**/target/**": true), rebuild and you won't get the message anymore.

All 12 comments

Can confirm the issue

λ cargo test --all
   Compiling cmark-gfm-sys v0.1.0 (/mnt/d/usr/dev/rust-cmark-gfm/cmark-gfm-sys)
warning: Error finalizing incremental compilation session directory `/mnt/d/usr/dev/rust-cmark-gfm/target/debug/incremental/build_script_build-n4xciywvi19s/s-fdds55f09n-q5jt9f-working`: Permission denied (os error 13)

warning: Error finalizing incremental compilation session directory `/mnt/d/usr/dev/rust-cmark-gfm/target/debug/incremental/cmark_gfm_sys-3ls9njfzb6ykh/s-fdds5eh9bn-12gpv22-working`: Permission denied (os error 13)

   Compiling cmark-gfm v0.1.0 (/mnt/d/usr/dev/rust-cmark-gfm)
warning: Error finalizing incremental compilation session directory `/mnt/d/usr/dev/rust-cmark-gfm/target/debug/incremental/cmark_gfm-z8zc4vraefh5/s-fdds5f2afx-cdxd8g-working`: Permission denied (os error 13)

warning: Error finalizing incremental compilation session directory `/mnt/d/usr/dev/rust-cmark-gfm/target/debug/incremental/cmark_gfm-deomkyug872w/s-fdds5f2gs3-1lwc7q9-working`: Permission denied (os error 13)

warning: Error finalizing incremental compilation session directory `/mnt/d/usr/dev/rust-cmark-gfm/target/debug/incremental/cmark_gfm_sys-191n3k9jxet3b/s-fdds5ehieo-11qz35a-working`: Permission denied (os error 13)

With WSL (pengwin / debian based) here

I had the same issue and it looks like this is not a problem with Rust but with the vscode Remote extension. They employ a file watcher that listens to file events to be notified about changes to files in an opened folder. Somehow that locks the files and causes permission errors.

You can work around the compiler warnings by either configuring the file watcher to use polling instead of events or by excluding the target/ directory from being watched. You can read more about that here: https://code.visualstudio.com/docs/remote/wsl#_i-see-eaccess-permission-denied-error-trying-to-rename-a-folder-in-the-open-workspace

@ra-kete That works. Thank you a lot!

This issue is happening for me even without any vs-code instance running.

warning: Error finalizing incremental compilation session directory `/home/95th/btrs/target/debug/incremental/btrs-311gr3ac8npws/s-fjgujplfts-i503kt-working`: Permission denied (os error 13)

This issue also happens to me, on debian10@WSL1. set vs-code remote.WSL.fileWatcher.polling to true does not help, exiting vs-code does not help, add wsl debian's rootfs folder to the excluding folder list of the Windows Defender does not help.

warning: Error finalizing incremental compilation session directory `/home/stone/projects/rabbit-dylib/target/debug/incremental/omcr-23necf7v4fs88/s-fjxwwz9bf3-7ohipt-working`: Permission denied (os error 13)

    Finished dev [unoptimized + debuginfo] target(s) in 0.13s

The last part of the warning path even does not exist, while the omcr-xxx folder exists:

stone@LAPTOP-Q3L7M1FS:~/projects/rabbit-dylib$ ll /home/stone/projects/rabbit-dylib/target/debug/incremental/
total 0
drwxrwxrwx 1 stone stone 4096 Jan 22 09:55 omcr-23necf7v4fs88
stone@LAPTOP-Q3L7M1FS:~/projects/rabbit-dylib$ ll /home/stone/projects/rabbit-dylib/target/debug/incremental/omcr-23necf7v4fs88/
total 0
stone@LAPTOP-Q3L7M1FS:~/projects/rabbit-dylib$

I had the same issue and it looks like this is not a problem with Rust but with the vscode Remote extension. They employ a file watcher that listens to file events to be notified about changes to files in an opened folder. Somehow that locks the files and causes permission errors.

You can work around the compiler warnings by either configuring the file watcher to use polling instead of events or by excluding the target/ directory from being watched. You can read more about that here: https://code.visualstudio.com/docs/remote/wsl#_i-see-eaccess-permission-denied-error-trying-to-rename-a-folder-in-the-open-workspace

great!

This issue is happening for me even without any vs-code instance running.

warning: Error finalizing incremental compilation session directory `/home/95th/btrs/target/debug/incremental/btrs-311gr3ac8npws/s-fjgujplfts-i503kt-working`: Permission denied (os error 13)

delete the target folder, exclude future target folders from being watched with files.watcherExclude (e.g. "**/target/**": true), rebuild and you won't get the message anymore.

Still happening today without any VS code running

I have the same issue as @95th. Also happens without an instance of VS code running. Did you ever find a fix?

I think this happens when you send SIGKILL to the cargo build process before it finishes. The next cargo build would emit this error.

Upgrading to wsl2 and deleting the target folder solved the issue.

I've reported one of the underlying issues against cargo here: https://github.com/rust-lang/cargo/issues/8830. I think there might be multiple underlying issues, one of which is that cargo doesn't seem to be safe when run concurrently. I haven't yet looked/raised one for that.

This underlying issue is that cargo is showing cached build output. If that output printed an error, but succeeded, cargo would repeatably show the error output from the previous build. Hence seeing things like permission errors which are no longer present, or attempting to delete files which no longer exist.

Was this page helpful?
0 / 5 - 0 ratings