Skip to content

Commit 62b7d31

Browse files
committed
Merge pull request #14369 from stevengj/fixrecompile
always create new cache files in default path when recompiling
2 parents 53978e7 + 06de426 commit 62b7d31

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

base/loading.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,13 +540,10 @@ end
540540
function recompile_stale(mod, cachefile)
541541
path = find_in_path(string(mod), nothing)
542542
if path === nothing
543-
rm(cachefile)
544-
error("module $mod not found in current path; removed orphaned cache file $cachefile")
543+
error("module $mod not found in current path; you should rm(\"$(escape_string(cachefile))\") to remove the orphaned cache file")
545544
end
546545
if stale_cachefile(path, cachefile)
547546
info("Recompiling stale cache file $cachefile for module $mod.")
548-
if !success(create_expr_cache(path, cachefile))
549-
error("Failed to precompile $mod to $cachefile")
550-
end
547+
compilecache(mod)
551548
end
552549
end

test/compile.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Base.Test
44

55
dir = mktempdir()
6+
dir2 = mktempdir()
67
insert!(LOAD_PATH, 1, dir)
78
insert!(Base.LOAD_CACHE_PATH, 1, dir)
89
Foo_module = :Foo4b3a94a1a081a8cb
@@ -71,6 +72,16 @@ try
7172
end
7273
Base.compilecache("FooBar")
7374
sleep(2)
75+
@test isfile(joinpath(dir, "FooBar.ji"))
76+
77+
touch(FooBar_file)
78+
insert!(Base.LOAD_CACHE_PATH, 1, dir2)
79+
Base.recompile_stale(:FooBar, joinpath(dir, "FooBar.ji"))
80+
sleep(2)
81+
@test isfile(joinpath(dir2, "FooBar.ji"))
82+
@test Base.stale_cachefile(FooBar_file, joinpath(dir, "FooBar.ji"))
83+
@test !Base.stale_cachefile(FooBar_file, joinpath(dir2, "FooBar.ji"))
84+
7485
open(FooBar_file, "w") do f
7586
print(f, """
7687
__precompile__(true)
@@ -83,9 +94,10 @@ try
8394
@test_throws ErrorException Base.require(:FooBar)
8495

8596
finally
86-
splice!(Base.LOAD_CACHE_PATH, 1)
97+
splice!(Base.LOAD_CACHE_PATH, 1:2)
8798
splice!(LOAD_PATH, 1)
8899
rm(dir, recursive=true)
100+
rm(dir2, recursive=true)
89101
end
90102

91103
# test --compilecache=no command line option

0 commit comments

Comments
 (0)