Skip to content
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

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

Closed
sirno opened this issue Oct 12, 2022 · 2 comments
Labels
C-bug Category: bug

Comments

@sirno
Copy link

sirno commented Oct 12, 2022

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]
@sirno sirno added the C-bug Category: bug label Oct 12, 2022
@epage
Copy link
Contributor

epage commented Oct 12, 2022

FYI in the future, you might run into problems with #10736

One workaround is to put [workspace] in your project which will tell cargo it shouldn't walk up the directory hierarchy to find if a Cargo.toml with a [workspace] exists.

@sirno
Copy link
Author

sirno commented Oct 12, 2022

Thank you so much. This works. I am closing this issue.

@sirno sirno closed this as completed Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants