-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
linux: fix invalid cross-device link error #8437
Conversation
We require contributors to sign our Contributor License Agreement, and we don't have @ASjet on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
In atomic_write use the write path as the temp dir can ensure the temp file is in the same filesystem. Use XDG_CACHE_DIR as a fallback
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.
Thank you!
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.
Thank you!
crates/zed/src/main.rs
Outdated
@@ -481,6 +481,11 @@ fn init_paths() { | |||
std::fs::create_dir_all(&*util::paths::LANGUAGES_DIR).expect("could not create languages path"); | |||
std::fs::create_dir_all(&*util::paths::DB_DIR).expect("could not create database path"); | |||
std::fs::create_dir_all(&*util::paths::LOGS_DIR).expect("could not create logs path"); | |||
|
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.
Could we remove this comment?
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.
Sure!
It also looks like this needs a |
This PR fix the "invalid cross-device link" error occurred in linux when trying to write the settings file atomically, like when click the "Enable vim mode" checkbox at first start.
Currently the
fs::RealFs::atomic_write()
method write to a temp file created withNamedTempFile::new()
and then callpersist()
method to write to the config file path, which actually do arename
syscall under the hood. As the issue saidThe temporary file directory in linux is in
/tmp
, which is mounted totmpfs
filesystem, and in most case(all case I guess)$HOME/.config/zed
is mounted to a different filesystem. And therename
syscall between different filesystems will return aEXDEV
errno, as described in the man page rename(2):And as the issue above said, use a different temp dir with
NamedTempFile::new_in()
for linux platform might be a solution, since therename
syscall provides atomicity.Release Notes:
settings.json
save failed with invalid cross-device link error in linux