diff --git a/base/loading.jl b/base/loading.jl index 37e5111bfbf5b..a6145398946b8 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1354,8 +1354,8 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in open(tmppath, "a+") do f write(f, _crc32c(seekstart(f))) end - # inherit permission from the source file - chmod(tmppath, filemode(path) & 0o777) + # inherit permission from the source file (and make them writable) + chmod(tmppath, filemode(path) & 0o777 | 0o200) # Read preferences hash back from .ji file (we can't precompute because # we don't actually know what the list of compile-time preferences are without compiling) diff --git a/test/precompile.jl b/test/precompile.jl index 2fcad7f64113c..08e945e1e3339 100644 --- a/test/precompile.jl +++ b/test/precompile.jl @@ -826,6 +826,10 @@ precompile_test_harness("Issue #25971") do load_path chmod(sourcefile, 0o600) cachefile = Base.compilecache(Base.PkgId("Foo25971")) @test filemode(sourcefile) == filemode(cachefile) + chmod(sourcefile, 0o444) + cachefile = Base.compilecache(Base.PkgId("Foo25971")) + # Check writable + @test touch(cachefile) == cachefile end precompile_test_harness("Issue #38312") do load_path