Skip to content

Commit 7d3cbd8

Browse files
IanButterworthgiordano
authored andcommitted
rename: invalid -> incompatible cache header (#56240)
Falling back to the older serial precompilation process is basically a bug (except for if a manifest hasn't been resolved) so #52619 added more info on why it's been hit so we have a chance of fixing issues that are otherwise very difficult to recreate. However "invalid header" which usually just means it was made by a different julia version appears to sound too alarming to users. https://discourse.julialang.org/t/cache-misses-when-using-packages-since-upgrading-to-1-11/121445 So soften it there and in error messages, given it seems a better description. Suggested by @giordano in https://discourse.julialang.org/t/cache-misses-when-using-packages-since-upgrading-to-1-11/121445/4?u=ianshmean (cherry picked from commit aa51abe)
1 parent a10b94f commit 7d3cbd8

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

base/loading.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
12101210
else
12111211
io = open(path, "r")
12121212
try
1213-
iszero(isvalid_cache_header(io)) && return ArgumentError("Invalid header in cache file $path.")
1213+
iszero(isvalid_cache_header(io)) && return ArgumentError("Incompatible header in cache file $path.")
12141214
_, (includes, _, _), _, _, _, _, _, _ = parse_cache_header(io, path)
12151215
ignore_native = pkg_tracked(includes)
12161216
finally
@@ -1831,7 +1831,7 @@ function isrelocatable(pkg::PkgId)
18311831
isnothing(path) && return false
18321832
io = open(path, "r")
18331833
try
1834-
iszero(isvalid_cache_header(io)) && throw(ArgumentError("Invalid header in cache file $cachefile."))
1834+
iszero(isvalid_cache_header(io)) && throw(ArgumentError("Incompatible header in cache file $cachefile."))
18351835
_, (includes, includes_srcfiles, _), _... = _parse_cache_header(io, path)
18361836
for inc in includes
18371837
!startswith(inc.filename, "@depot") && return false
@@ -1906,7 +1906,7 @@ function _tryrequire_from_serialized(pkg::PkgId, path::String, ocachepath::Union
19061906
io = open(path, "r")
19071907
ignore_native = false
19081908
try
1909-
iszero(isvalid_cache_header(io)) && return ArgumentError("Invalid header in cache file $path.")
1909+
iszero(isvalid_cache_header(io)) && return ArgumentError("Incompatible header in cache file $path.")
19101910
_, (includes, _, _), depmodnames, _, _, _, clone_targets, _ = parse_cache_header(io, path)
19111911

19121912
ignore_native = pkg_tracked(includes)
@@ -3049,7 +3049,7 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
30493049
# append extra crc to the end of the .ji file:
30503050
open(tmppath, "r+") do f
30513051
if iszero(isvalid_cache_header(f))
3052-
error("Invalid header for $(repr("text/plain", pkg)) in new cache file $(repr(tmppath)).")
3052+
error("Incompatible header for $(repr("text/plain", pkg)) in new cache file $(repr(tmppath)).")
30533053
end
30543054
seekend(f)
30553055
write(f, crc_so)
@@ -3358,7 +3358,7 @@ end
33583358
function parse_cache_header(cachefile::String)
33593359
io = open(cachefile, "r")
33603360
try
3361-
iszero(isvalid_cache_header(io)) && throw(ArgumentError("Invalid header in cache file $cachefile."))
3361+
iszero(isvalid_cache_header(io)) && throw(ArgumentError("Incompatible header in cache file $cachefile."))
33623362
ret = parse_cache_header(io, cachefile)
33633363
return ret
33643364
finally
@@ -3371,7 +3371,7 @@ function preferences_hash(cachefile::String)
33713371
io = open(cachefile, "r")
33723372
try
33733373
if iszero(isvalid_cache_header(io))
3374-
throw(ArgumentError("Invalid header in cache file $cachefile."))
3374+
throw(ArgumentError("Incompatible header in cache file $cachefile."))
33753375
end
33763376
return preferences_hash(io, cachefile)
33773377
finally
@@ -3387,7 +3387,7 @@ end
33873387
function cache_dependencies(cachefile::String)
33883388
io = open(cachefile, "r")
33893389
try
3390-
iszero(isvalid_cache_header(io)) && throw(ArgumentError("Invalid header in cache file $cachefile."))
3390+
iszero(isvalid_cache_header(io)) && throw(ArgumentError("Incompatible header in cache file $cachefile."))
33913391
return cache_dependencies(io, cachefile)
33923392
finally
33933393
close(io)
@@ -3427,7 +3427,7 @@ end
34273427
function read_dependency_src(cachefile::String, filename::AbstractString)
34283428
io = open(cachefile, "r")
34293429
try
3430-
iszero(isvalid_cache_header(io)) && throw(ArgumentError("Invalid header in cache file $cachefile."))
3430+
iszero(isvalid_cache_header(io)) && throw(ArgumentError("Incompatible header in cache file $cachefile."))
34313431
return read_dependency_src(io, cachefile, filename)
34323432
finally
34333433
close(io)
@@ -3693,9 +3693,9 @@ end
36933693
try
36943694
checksum = isvalid_cache_header(io)
36953695
if iszero(checksum)
3696-
@debug "Rejecting cache file $cachefile due to it containing an invalid cache header"
3697-
record_reason(reasons, "invalid header")
3698-
return true # invalid cache file
3696+
@debug "Rejecting cache file $cachefile due to it containing an incompatible cache header"
3697+
record_reason(reasons, "incompatible header")
3698+
return true # incompatible cache file
36993699
end
37003700
modules, (includes, _, requires), required_modules, srctextpos, prefs, prefs_hash, clone_targets, actual_flags = parse_cache_header(io, cachefile)
37013701
if isempty(modules)

stdlib/Logging/docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ module. Loading julia with `JULIA_DEBUG=loading` will activate
191191

192192
```
193193
$ JULIA_DEBUG=loading julia -e 'using OhMyREPL'
194-
┌ Debug: Rejecting cache file /home/user/.julia/compiled/v0.7/OhMyREPL.ji due to it containing an invalid cache header
194+
┌ Debug: Rejecting cache file /home/user/.julia/compiled/v0.7/OhMyREPL.ji due to it containing an incompatible cache header
195195
└ @ Base loading.jl:1328
196196
[ Info: Recompiling stale cache file /home/user/.julia/compiled/v0.7/OhMyREPL.ji for module OhMyREPL
197-
┌ Debug: Rejecting cache file /home/user/.julia/compiled/v0.7/Tokenize.ji due to it containing an invalid cache header
197+
┌ Debug: Rejecting cache file /home/user/.julia/compiled/v0.7/Tokenize.ji due to it containing an incompatible cache header
198198
└ @ Base loading.jl:1328
199199
...
200200
```

0 commit comments

Comments
 (0)