Skip to content

Incremental compilation does not work through mounted WSL folder on Windows #12650

@printfn

Description

@printfn

Problem

I have cargo installed via rustup on Windows, and cargo build fails with this error message when trying to build inside of a mounted WSL directory (i.e. \\wsl.localhost\Ubuntu\home\user\...):

PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Ubuntu\home\user\fend> cargo build
   Compiling fend-core v1.2.1 (\\wsl.localhost\Ubuntu\home\user\fend\core)
error: incremental compilation: could not create session directory lock file: Incorrect function. (os error -2147024895)
  |
  = help: incremental compilation can be disabled by setting the environment variable CARGO_INCREMENTAL=0 (see https://doc.rust-lang.org/cargo/reference/profiles.html#incremental)
  = help: the entire build directory can be changed to a different filesystem by setting the environment variable CARGO_TARGET_DIR to a different path (see https://doc.rust-lang.org/cargo/reference/config.html#buildtarget-dir)

error: could not compile `fend-core` (lib) due to previous error

Disabling incremental compilation with $env:CARGO_INCREMENTAL = "0" works, as does using a Linux version of cargo/rustc, but I was working on Windows-specific code and did not want to cross-compile, nor move my rust code outside WSL.

Steps

  1. Install rustup, cargo, rustc, etc. on Windows
  2. Set up a cargo project inside WSL
  3. Open a powershell window and run:
    cd \\wsl.localhost\Ubuntu\home\user\project
    $env:CARGO_INCREMENTAL = "0"
    cargo build

Possible Solution(s)

File locking should be fixed in this scenario, or incremental compilation should be disabled automatically.

Notes

No response

Version

cargo 1.72.0 (103a7ff2e 2023-08-15)
release: 1.72.0
commit-hash: 103a7ff2ee7678d34f34d778614c5eb2525ae9de
commit-date: 2023-08-15
host: x86_64-pc-windows-msvc
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.1.2-DEV (sys:0.4.63+curl-8.1.2 vendored ssl:Schannel)
os: Windows 10.0.22621 (Windows 11 Professional) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions