`cargo build` fails in WSL with filesystem-related errors

Open 💬 0 comments Opened Feb 6, 2026 by popzxc

What version of Codex CLI is running?

0.98.0

What subscription do you have?

plus

Which model were you using?

gpt-5.2-codex, gpt-5.3-codex

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64 (WSL2)

What terminal emulator and version are you using (if applicable)?

VSCode, Windows Terminal

What issue are you seeing?

Submitted logs: ID 019c31e6-de85-7e03-b54d-eaf910b1ea4c

I have Windows PC with WSL2, and I cannot get codex to build Rust projects.
It can build a simple project, e.g. right after cargo new --bin test-project, but it starts to fail if I add dependencies, e.g. cargo add serde_json.

The errors I get are similar to:

  Compiling itoa v1.0.17
  error: failed to write /home/<...>/test-project/target/debug/deps/libitoa-72cb3bfbf6020774.rmeta: Invalid cross-device link (os error 18)

  error: could not compile `itoa` (lib) due to 1 previous error
  warning: build failed, waiting for other jobs to finish...
  error: failed to write /home/<...>/test-project/target/debug/deps/libzmij-8ebfc237287fc0a7.rmeta: Invalid cross-device link (os error 18)

  error: could not compile `zmij` (lib) due to 1 previous error
  error: failed to write /home/<...>/test-project/target/debug/deps/libmemchr-d6ebc6aaa1ea128d.rmeta: Invalid cross-device link (os error 18)

  error: could not compile `memchr` (lib) due to 1 previous error
  error: failed to write /home/<...>/test-project/target/debug/deps/libserde_core-d4b9e6d523f0a0bc.rmeta: Invalid cross-device link (os error 18)

On a different project that uses a workspace and path dependencies, I also get the following warning:

warning: hard linking files in the incremental compilation cache failed. copying files instead.

It fails both on a fresh run (e.g. no target dir) and when target is already present.

Some suspicious things I've noticed:

  1. It has to build the project even if the project is already built, normally cargo would just print "Finished dev profile"; I guess it's an effect of the sandbox.
  2. Looking at the crates that fail to compile, it might be related to either C dependencies or build scripts being run. Again, seems to be related to the sandbox.

I don't have any special configs set in either codex config.toml or cargo config.toml, however I've tried:

  • Adding path to .cargo to the writable_roots
  • Disabling incremental compilation in cargo
  • Changing target/build dir in cargo

Nothing has helped so far.

I have not run it without sandbox personally, but the issue mentioned below confirms that without sandbox error seems to be gone.

Potentially relevant issues:

What steps can reproduce the bug?

  1. Start WSL session in windows terminal.
  2. cargo new --bin test-project
  3. cd test-project
  4. cargo add serde_json
  5. Run codex
  6. Prompt it: "Run cargo build and show me its output"
  7. Build fails with cross-device link errors.

What is the expected behavior?

Build succeeds

Additional information

I have no such problem on MacOS.

View original on GitHub ↗