-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
Use atomic writes when binding artifacts #3235
Conversation
src/Artifacts.jl
Outdated
open(artifacts_toml, "w") do io | ||
TOML.print(io, artifact_dict, sorted=true) | ||
end |
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, these lines are buggy, causing this failure. Pkg must never open an existing file for writing, as it causes problems for the filesystem.
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.
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.
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 JuliaLang/julia#46944 removed the check that was intended to catch things like this.
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.
It did, but that check was fundamentally flawed, and didn't actually check for things like this, it merely checked for attempts to test for this problem.
This ensures that the inode of the underlying `Artifacts.toml` file gets changed, which should properly invalidate Base's TOML cache.
26be300
to
96ac41b
Compare
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.
Excellent
Might as well shoot for all green given the stdlib check is fixed on master now |
@staticfloat This broke support for relative diff --git a/src/Artifacts.jl b/src/Artifacts.jl
index 538755e23..dca06e469 100644
--- a/src/Artifacts.jl
+++ b/src/Artifacts.jl
@@ -223,7 +223,8 @@ function bind_artifact!(artifacts_toml::String, name::String, hash::SHA1;
# Spit it out onto disk
let artifact_dict = artifact_dict
- temp_artifacts_toml = tempname(dirname(artifacts_toml))
+ parent_dir = dirname(artifacts_toml)
+ temp_artifacts_toml = isempty(parent_dir) ? : tempname(pwd()) : tempname(parent_dir)
open(temp_artifacts_toml, "w") do io
TOML.print(io, artifact_dict, sorted=true)
end or was this never a supported use case and ArtifactUtils should be updated? |
A patch like yours should be fine. |
This got broken in #3235. Fixes JuliaPackaging/ArtifactUtils.jl#19
This got broken in #3235. Fixes JuliaPackaging/ArtifactUtils.jl#19
This got broken in #3235. Fixes JuliaPackaging/ArtifactUtils.jl#19
This got broken in JuliaLang#3235. Fixes JuliaPackaging/ArtifactUtils.jl#19 (cherry picked from commit 79f5e3b)
EDIT: No longer doing this, Jameson has Shown Me The Way™
We need to clear this cache when modifying the TOML file. This should fix #3212.
It might be nice to expose a
Base.drop_parsed_toml(path::String)
API so that I don't have to manually reach intoTOML_CACHE.d
here like this.