Skip to content

Cargo cannot update crates.io index on NFS #6652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ebetica opened this issue Feb 11, 2019 · 6 comments
Open

Cargo cannot update crates.io index on NFS #6652

ebetica opened this issue Feb 11, 2019 · 6 comments
Labels
A-filesystem Area: issues with filesystems C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@ebetica
Copy link

ebetica commented Feb 11, 2019

I cannot use Cargo when my home directory is located on a networked file system (NFS)

Here is the error I get:

$ cargo install rg
    Updating crates.io index
warning: spurious network error (2 tries remaining): failed to truncate pack file '/private/home/misterabc/.cargo/registry/index/g.yxqyang.asia-1ecc6299db9ec823/.git/objects/pack/pack_git2_RVSwU3': Permission denied; class=Os (2)
warning: spurious network error (1 tries remaining): failed to truncate pack file '/private/home/misterabc/.cargo/registry/index/g.yxqyang.asia-1ecc6299db9ec823/.git/objects/pack/pack_git2_iAwQaT': Permission denied; class=Os (2)
error: failed to fetch `https://github.com/rust-lang/crates.io-index`                                                                       

Caused by:
  failed to truncate pack file '/private/home/misterabc/.cargo/registry/index/g.yxqyang.asia-1ecc6299db9ec823/.git/objects/pack/pack_git2_PMGzWR': Permission denied; class=Os (2)

Instead, if I do CARGO_HOME=/tmp/.cargo cargo install rg, everything seems to work out fine.

Steps

  1. CARGO_HOME=/path/to/nfs/.cargo cargo install rg, probably any package will cause this error

Notes

  • cargo 1.31.0 (339d9f9 2018-11-16)
  • Ubuntu 18.04
@ebetica ebetica added the C-bug Category: bug label Feb 11, 2019
@alexcrichton
Copy link
Member

Thanks for the report! This looks like it's likely coming from libgit2 so it may not be trivial to fix. What's probably happening is that some syscall libgit2 is expecting to work doesn't work on NFS. Can you try running strace to figure out what the failing syscall is? It'd also be great to get the stack trace at the time of failure of that syscall.

@ebetica
Copy link
Author

ebetica commented Feb 12, 2019

Here's the strace: https://gist.github.com/ebetica/1b77fdf65432ae894fc758a7e9ca1f43

I'm not sure how to get the stack trace. I think the problem is in ftruncate, no? It appears to me that the git pack files are created with only read permissions, where ftruncate expect it to be opened with write permissions?

@alexcrichton
Copy link
Member

Ah ok! Looks like this may be the same as #1578? I thought there was a flag for strace to print stacks but I may also be remembering incorrectly...

@felipellrocha
Copy link

I have found a workaround for this issue:

Adding,

[net]
git-fetch-with-cli = true

to .cargo/config fixes the issue

@ashthespy
Copy link

ashthespy commented Mar 13, 2020

Have run into the same issue with a rust corssbuild docker container on a windows machine, which earlier worked fine. FWIW, I use the default --mount flag to mount the cache folder:

Building aarch64 with cargo build --release --target aarch64-unknown-linux-gnu --verbose
    Updating git repository `https://github.com/ashthespy/librespot`
warning: spurious network error (2 tries remaining): failed to truncate pack file '/build/cache/git/db/librespot-6f197fd632ef9380/objects/pack/pack_git2_wCQpdD': Operation not permitted; class=Os (2)
warning: spurious network error (1 tries remaining): failed to truncate pack file '/build/cache/git/db/librespot-6f197fd632ef9380/objects/pack/pack_git2_yWscE9': Operation not permitted; class=Os (2)
error: failed to load source for a dependency on `librespot`

Caused by:
  Unable to update https://github.com/ashthespy/librespot?branch=vollibrespot#46749460

Caused by:
  failed to fetch into /build/cache/git/db/librespot-6f197fd632ef9380

Caused by:
  failed to truncate pack file '/build/cache/git/db/librespot-6f197fd632ef9380/objects/pack/pack_git2_ztnTVN': Operation not permitted; class=Os (2)

File permissions

root@56957e7897a3:/src# ls -la /build/cache/git/
total 0
drwxrwxrwx 1 root root 0 Mar 13 23:49 .
drwxrwxrwx 1 root root 0 Mar 13 23:49 ..
drwxrwxrwx 1 root root 0 Mar 13 23:49 checkouts
drwxrwxrwx 1 root root 0 Mar 14 00:17 db

kodiakhq bot added a commit to journalio/journali-devops that referenced this issue Apr 15, 2020
Adds a cargo configuration file to docker to fix `failed to truncate pack file`.
See rust-lang/cargo#6652
@ashthespy
Copy link

The workaround from @felipellrocha seems to work inside the container, but any pointers on how to debug this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-filesystem Area: issues with filesystems C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

6 participants