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

Prevent editing of cargo-private registry files #469

Closed
kornelski opened this issue Aug 20, 2021 · 3 comments
Closed

Prevent editing of cargo-private registry files #469

kornelski opened this issue Aug 20, 2021 · 3 comments

Comments

@kornelski
Copy link

Sublime Text Version

4133

Rust Enhanced Version

2.24.0

Operating system

macOS Big Sur

Expected behavior

Users are not supposed to edit Rust source files inside CARGO_HOME (~/.cargo/registry), since these are meant to be immutable snapshots of crates. These files are treated as disposable, so users editing them by accident can lose their work.

Rust-analyzer's "jump to definition" function will happily jump to these files. This makes it easy to accidentally open a file of a dependency. Jumping to view these files is not bad per-se, but editing them by accident is problematic.

Actual behavior

Could you open Cargo registry files in read-only mode? Or show some kind of warning that the file is not supposed to be edited?

Steps to reproduce

  1. subl ~/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.99/src/lib.rs

References

@ehuss
Copy link

ehuss commented Aug 20, 2021

I'm not too familiar with the LSP plugin, but I think that would be responsible for setting the view read-only.

This plugin does this already (see here). When using the build system, if there is a diagnostic that points to something outside of the workspace, the view is opened read-only.

@kornelski
Copy link
Author

I initially filed the request with rust-analyzer, but LSP can't do it, which is why they sent me here :)

@ehuss
Copy link

ehuss commented Jun 11, 2022

I'm going to close as I don't think there is anything this extension can do. The LSP extension is a separate project. I suspect it wouldn't be possible for it to know whether or not the file should be read-only (unless that is part of the LSP protocol).

We are looking to make the src cache read-only over at rust-lang/cargo#9455, though we ran into some problems which will need some more work.

I realize this is an annoying issue, and trips up people quite a bit. Hopefully progress can be made on the cargo side.

@ehuss ehuss closed this as completed Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants