Skip to content

Cargo tries to access ignored files, resulting in errors if unreadable #8092

@Restioson

Description

@Restioson

Problem
When a build.rs is present, a non-owned and ill-permissioned directory in a Cargo project can cause Cargo to fail, even if it is in the .gitignore and in the package.exclude section.

Expected behaviour: cargo ignores the file/directory and checks the project correctly.
Observed behaviour: the following error:

error: cannot read "reprod/undelveable"

Caused by:
  Permission denied (os error 13)

Steps
Run the following script to reproduce:

#!/bin/sh

cargo new reprod
cd reprod
echo "fn main() {}" >> build.rs
mkdir undelveable
echo "undelveable/" >> .gitignore
sed -i 's/edition = "2018"/edition = "2018"\nexclude = ["undelveable"]/' Cargo.toml
chmod 0711 undelveable
touch undelveable/unreadable
sudo chown root:root undelveable
cargo check

Notes

  • cargo 1.42.0 (8633429 2020-01-31)
  • Pop!_OS Ubuntu-based Linux distribution
  • Stable cargo

Metadata

Metadata

Assignees

Labels

C-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions