Opened 6 months ago

Closed 5 months ago

#29244 closed defect (fixed)

Travis permissions error: failed to write Cargo.lock

Reported by: teor Owned by: nickm
Priority: High Milestone: Tor: 0.3.3.x-final
Component: Core Tor/Tor Version:
Severity: Major Keywords: 041-proposed, tor-ci, regression, 040-backport 035-backport 034-backport 033-backport
Cc: Actual Points: .2
Parent ID: Points: 0.5
Reviewer: Sponsor:

Description

Let's monitor this error, and see if it happens again.

From https://trac.torproject.org/projects/tor/ticket/23576?replyto=24#comment:24

error: failed to write /home/travis/build/torproject/tor/tor-0.4.0.1-alpha-dev/src/rust/Cargo.lock

Caused by:
  failed to open: /home/travis/build/torproject/tor/tor-0.4.0.1-alpha-dev/src/rust/Cargo.lock

Caused by:
  Permission denied (os error 13)

https://travis-ci.org/torproject/tor/jobs/486721901#L3634

Child Tickets

Change History (15)

comment:1 Changed 6 months ago by teor

This issue appears to be reproducible:
https://travis-ci.org/torproject/tor/jobs/486795693#L3638

comment:2 Changed 6 months ago by teor

This appears to be a build environment issue, because the same commit succeeded 4 days ago, but failed 2 days ago:
https://travis-ci.org/torproject/tor/builds/485707435
https://travis-ci.org/torproject/tor/builds/484917361

It is probably related to Rust 1.32.0, which was released 14 days ago.

comment:3 Changed 6 months ago by nickm

Keywords: 040-backport 035-backport 034-backport 033-backport? added

comment:4 in reply to:  2 Changed 6 months ago by catalyst

Replying to teor:

This appears to be a build environment issue, because the same commit succeeded 4 days ago, but failed 2 days ago:
https://travis-ci.org/torproject/tor/builds/485707435
https://travis-ci.org/torproject/tor/builds/484917361

It is probably related to Rust 1.32.0, which was released 14 days ago.

Did cargo start trying to write to Cargo.lock, even in frozen mode? I think this is happening in the distcheck jobs because maybe it tries to make the source tree read-only.

comment:5 Changed 6 months ago by nickm

It's also possible that we stopped using frozen mode somewhere by mistake.

comment:6 Changed 6 months ago by nickm

It might be related to rust nightly, since it seems we're using that:

$ if [[ "$RUST_OPTIONS" != "" ]]; then rustc --version; fi
rustc 1.34.0-nightly (d8a0dd7ae 2019-01-28)

comment:7 Changed 6 months ago by teor

Cargo recently started adding a comment to the start of the file:
https://github.com/rust-lang/cargo/commit/3de188f1399da693c57054ed425bc0289752edd1

But cargo checks for frozen before writing. We are getting the write failed error, not the frozen error.
https://github.com/rust-lang/cargo/blob/3de188f1399da693c57054ed425bc0289752edd1/src/cargo/ops/lockfile.rs#L105

comment:8 Changed 6 months ago by nickm

Milestone: Tor: 0.4.1.x-finalTor: 0.4.0.x-final
Owner: set to nickm
Status: newaccepted

comment:9 Changed 6 months ago by nickm

Aha, here is the bug.

When we say --enable-cargo-online-mode, we do not provide the "--frozen" flag as part of $CARGO_ONLINE.

This flag both gives cargo permission to download (which we want, since we're doing distcheck with --enable-cargo-online-mode) and gives it permission to update cargo.lock (which we don't, in this case).

comment:10 Changed 6 months ago by nickm

Keywords: 033-backport added; 033-backport? removed

comment:11 Changed 6 months ago by nickm

Actual Points: .2
Status: acceptedneeds_review

https://github.com/torproject/tor/pull/676 is a PR to fix this; the branch is ticket29244_033

comment:12 Changed 6 months ago by nickm

There is a case to be made that we should be using cargo's "--locked" option in this case, but I am going to suggest that we don't: It's not a great idea IMO to do things differently in a distcheck build.

comment:13 Changed 5 months ago by ahf

Status: needs_reviewmerge_ready

This looks like a reasonable fix for me. I did not try to build it with nightly locally.

comment:14 in reply to:  7 Changed 5 months ago by arma

Replying to teor:

Cargo recently started adding a comment to the start of the file:
https://github.com/rust-lang/cargo/commit/3de188f1399da693c57054ed425bc0289752edd1

But cargo checks for frozen before writing. We are getting the write failed error, not the frozen error.
https://github.com/rust-lang/cargo/blob/3de188f1399da693c57054ed425bc0289752edd1/src/cargo/ops/lockfile.rs#L105

For posterity, the above comments are where the fix comes from.

<ahf> armadev: the problem is that the place where tor.git is located is read/only, when we run distcheck it runs cargo which modifies the file by adding those two comments
<ahf> but because it's read-only it will fail
<ahf> but if those two lines of comment is there cargo wont touch the file

comment:15 Changed 5 months ago by arma

Milestone: Tor: 0.4.0.x-finalTor: 0.3.3.x-final
Resolution: fixed
Status: merge_readyclosed

it is merged into maint-0.3.3 and later

Note: See TracTickets for help on using tickets.