-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Use TempDir
for copied lockfiles
#20290
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
base: master
Are you sure you want to change the base?
Conversation
@@ -156,6 +156,7 @@ smallvec = { version = "1.15.1", features = [ | |||
"const_generics", | |||
] } | |||
smol_str = "0.3.2" | |||
temp-dir = "0.1.16" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose this crate because it uses short, safe Rust codes and has no deps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL temp-dir
(besides tempdir
, which is very popular, and tempfile
, which is unmaintained).
_temp_dir_guard = temp_dir::TempDir::new().ok(); | ||
let target_lockfile = _temp_dir_guard | ||
.and_then(|tmp| tmp.path().join("Cargo.lock").try_into().ok()) | ||
.unwrap_or_else(|| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think failures on creating TempDir
or converting it to Utf8PathBuf
would be quite rare, but copied disambiguation from #20244 into this fallback anyway
// The manifest is a rust file, so this means its a script manifest | ||
if let Some(lockfile) = lockfile_path { | ||
let target_lockfile = | ||
target_dir.join("rust-analyzer").join("metadata").join(kind).join("Cargo.lock"); | ||
_temp_dir_guard = temp_dir::TempDir::new().ok(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set a prefix here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not necessary but having one would be good to some curious people who look into their /tmp/
. Do you have some recommendations for prefix string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something with rust-analyzer
or r-a
? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have one for the proc-macro server already I think on windows (where we copy the proc macro dylibs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah well, doesn't matter I guess as that is proc-macro specific
to.push("rust-analyzer-proc-macros"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I just found that we also have a RemoveFileOnDrop
for Windows there as well 😅
e882f86
to
d5379d3
Compare
Fixes #20189 and closes #20244 and fixes #20113