JuliaPackaging / Scratch.jl

Scratch spaces for all your persistent mutable data needs
MIT License
58 stars 11 forks source link

Add JULIA_TRACK_SCRATCH_ACCESS env variable, to allow disabling tracking of scratch access #34

Closed rbvermaa closed 1 year ago

rbvermaa commented 1 year ago

Add JULIA_TRACK_SCRATCH_ACCESS env variable, to allow disabling tracking of scratch access. Set to JULIA_TRACK_SCRATCH_ACCESS=0 to disable.

Rationale: we use PackageCompiler.jl to generate a readonly build artifact for deployment. PackageCompiler sets the depot path in the created executable, here: https://github.com/JuliaLang/PackageCompiler.jl/blob/master/src/embedding_wrapper.c#L96 When building the package, we make sure the scratchspaces are filled as expected, however, Scratch.jl wants to write a log of the usage, which we do not want. This PR would allow us to disable this logging. We also tried running the PackageCompiler binary with an extended DEPOT_PATH (where the first path in would be writable), however, this will cause the scratchspaces to be created on the first runtime execution, which is not desirable (wrt reproducibility and possible runtime errors, eg. download/network issues ).

rbvermaa commented 1 year ago

Seems fine. Doesn't Pkg have the same problem though? Perhaps there should be generic flag that also Pkg uses?

We haven't run into issues with Pkg, fortunately.

rbvermaa commented 1 year ago

@fredrikekre Applied the rename you suggested. Thanks!

fredrikekre commented 1 year ago

Just to confirm, the problem here is that Scratch.jl writes the logfile when accessing it, i.e. during "runtime", whereas Pkg only prints usage logs in Pkg.instantiate?

rbvermaa commented 1 year ago

Just to confirm, the problem here is that Scratch.jl writes the logfile when accessing it, i.e. during "runtime", whereas Pkg only prints usage logs in Pkg.instantiate?

I think that is the case, yes.

rbvermaa commented 1 year ago

@fredrikekre Anything preventing this from being merged?

fredrikekre commented 1 year ago

Could maybe use the get_bool_env thing in Base to also support setting it to false etc.