Skip to content

Package caching on NixOS causes crash due to immutable nix store being used as cache dir #455

@EvelynTheSilly

Description

@EvelynTheSilly

Describe the bug
when running "cargo mobile android run" on Nixos it attempts to cache packages in the nix store, then proceeds to crash because the nix store is immutable
here is a snippet of the error log

warning: failed to write cache, path: /nix/store/7n7pchllxzcywrkdfm391hvbsmdcqbla-cargo-mobile2-0.17.6/share/registry/index/index.crates.io-1949cf8c6b5b557f/.cache/an/yh/anyhow, error: Read-only file system (os error 30)
 Downloading crates ...
  Downloaded fxhash v0.2.1
error: failed to create directory `/nix/store/7n7pchllxzcywrkdfm391hvbsmdcqbla-cargo-mobile2-0.17.6/share/registry/cache/index.crates.io-1949cf8c6b5b557f`

Caused by:
  Read-only file system (os error 30)

Steps To Reproduce

  • use nixos
  • make a new project using wry template
  • cargo mobile android run
  • error

Expected behavior
not caching to the nix store

Platform and Versions (please complete the following information):
Host OS: Nixos 25.05 using unstable channel
Target OS: android
Rustc: 1.86
Ouput of cargo mobile doctor:

[✔] cargo-mobile v0.17.6
• Contains commits up to ""
• Installed at "/nix/store/7n7pchllxzcywrkdfm391hvbsmdcqbla-cargo-mobile2-0.17.6/share/.cargo-mobile2"
• NixOS v25.05 (Warbler
• rustc v1.86.0 (05f9846f8 2025-3-31)

[✔] Android developer tools
• SDK v35.0.2 installed at "/nix/store/csbkx8zn34p2whidjkypn1vkq6d09l07-androidsdk/libexec/android-sdk"
• NDK v23.1.7779620 installed at "/nix/store/csbkx8zn34p2whidjkypn1vkq6d09l07-androidsdk/libexec/android-sdk/ndk-bundle"

[✔] Connected devices
• Pixel 6a

Additional context
if it wasnt obvious from before, the nix store (/nix/store) is immutable, thus caching to it causes and os error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions