Skip to content

Cargo build tries to read files that it has no permissions for (Permission denied (os error 13)) #11220

@sirno

Description

@sirno

Problem

I want to compile my code on a cluster. Clusters are messy sometimes, and as such in the /home directory of our system someone or something made a mess, creating all sorts of directories, one of which is called Cargo.toml.

When building Cargo.toml the compiler fails:

error: failed to read `/Users/Cargo.toml`

Caused by:
  Permission denied (os error 13)

Steps

These work on any system :)

  1. cd ~/..
  2. sudo mkdir Cargo.toml or sudo touch Cargo.toml
  3. sudo chmod 300 Cargo.toml
  4. try to compile any project...

Possible Solution(s)

Probably plenty

  • Check permissions before writing files
  • Do not read stuff outside of the user directory
  • Blacklist or whiltelist search paths

Notes

No response

Version

cargo 1.64.0 (387270bc7 2022-09-16)
release: 1.64.0
commit-hash: 387270bc7f446d17869c7f208207c73231d6a252
commit-date: 2022-09-16
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1q)
os: CentOS 7.9.2009 (Core) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions