cargo: Failed to mmap

I can’t install anything with cargo.

$ cargo install --verbose rustfmt
    Updating registry `https://github.com/rust-lang/crates.io-index`
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  [2/-1] Failed to mmap. Could not write data: Invalid argument

or by putting dependency in Cargo.toml

$ cat Cargo.toml
[package]
name = "test"
version = "0.1.0"
authors = ["test"]

[dependencies]
rustfmt = "0.5"
$ cargo build --verbose
    Updating registry `https://github.com/rust-lang/crates.io-index`
error: Unable to update registry https://github.com/rust-lang/crates.io-index

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  [2/-1] Failed to mmap. Could not write data: Invalid argument
$ rustc --version
rustc 1.9.0 (e4e8b6668 2016-05-18)
$ cargo --version
cargo 0.10.0-nightly (10ddd7d 2016-04-08)

I am running up-to-date Ubuntu 16.04 LTS.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 35 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I think I have hit the same issue on OSX while wanting to be clever and reuse cargo registry between builds on a docker:

docker run \
    -v $(pwd)/build/.cargo:/root/.cargo \
    -v $(pwd):/source jimmycuadra/rust:1.15.0 \
    /bin/bash -c "cargo build --release"
    Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): [2/-1] Failed to mmap. Could not write data: Invalid argument
warning: spurious network error (1 tries remaining): [2/-1] Failed to mmap. Could not write data: Invalid argument
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Just have met the same bug in WSL ubuntu-20.

A hint for who has the same issue:

Using local docker volume to map .cargo won’t trigger this.

docker run ... -v cargo-cache:/root/.cargo

The .cargo will be cached between different containers as expected.

Hi @williamdes thank you. Yes this works ))

You should try the workaround I used on my docker image for armv6/armv7 See: https://github.com/rust-lang/cargo/issues/6513#issuecomment-1440029221

ENV CARGO_NET_GIT_FETCH_WITH_CLI=true

Please let us know if works for you

@jml Sorry, no. My project is very small so this is minor for me.