JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
821 stars 94 forks source link

[BUG] `weave` with some doctypes creates a tempdir that is not deleted #440

Open bencottier opened 2 years ago

bencottier commented 2 years ago

description

Using weave with doctype=md2html and leaving fig_path unspecified results in a temp dir (the kind made by mktempdir) left in the out_path. My guess is this code is responsible.

This behaviour is inconsistent with the doc, which says it will default to DEFAULT_FIG_PATH:

  • fig_path::Union{Nothing,AbstractString} = nothing: Where figures will be generated, relative to out_path. By default (i.e. given nothing), Weave will automatically create $(DEFAULT_FIG_PATH) directory.

If a tempdir is used, I would expect it to be deleted after calling the function that creates it.

versions

using InteractiveUtils; versioninfo():

Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
JULIA_EDITOR = code

using Pkg; Pkg.status():

julia> using Pkg; Pkg.status()
Status `/private/var/folders/g6/w_cfz8c507j6mbt5mdv7wt_h0000gn/T/jl_bzbN9C/Project.toml`
[44d3d7a6] Weave v0.10.10

minimum reproducible steps

I have only tested with doctype="md2html" but I think it would be true of any doctype that ends with "2pdf" or "2html".

Example document called weave_test.jl:

#' ## Test
x = 1

weave call which creates a tempdir that is not deleted:

weave("./weave_test.jl"; doctype="md2html", out_path=".")

weave call which creates a "figures" dir as expected, and no tempdir:

 weave("./weave_test.jl"; doctype="md2html", out_path=".", fig_path="figures")

The output HTML is as expected: image

slwu89 commented 2 years ago

I can confirm I have the same issue when weaving .jmd files. My platform is:

julia> using InteractiveUtils; versioninfo()
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.1.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, cyclone)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 

and package version:

julia> using Pkg; Pkg.status()
      Status `~/.julia/environments/v1.7/Project.toml`
  [44d3d7a6] Weave v0.10.10

When using a file called test.jmd with:

# hello

this is a test!

```julia 
5 + 5


after calling `weave("test.jl")` in the directory with output there is a temp folder that was not cleaned up "jl_X8p1Qs"