Weave hangs when trying to generate a plot

I have a histogram inside a jmd file that I want to plot:

```julia; echo = false
    using Plots
    gr()
    h = histogram(WEAVE_ARGS.dict["p_reads"], label="", 
                xlabel="Number of reads", 
                linecolor="white", 
                normalize=:probability,
                xtickfontsize=10,ytickfontsize=10,
                color=:mediumturquoise, size=(500,350), bins = 25,
                xlim=((25, 125)),
                ylabel="Relative frequency", 
                title="gRNA frequency distribution") ```

Which makes Weave hang:

┌ Info: Weaving chunk 1 from line 24
└   progress = 0.0
┌ Info: Weaving chunk 2 from line 46
└   progress = 0.25
┌ Info: Weaving chunk 3 from line 55
└   progress = 0.5

Plotting from the command line works fine:

julia> @time histogram(p_reads, label="", 
                   xlabel="Number of reads", 
                   linecolor="white", 
                   normalize=:probability,
                   xtickfontsize=10,ytickfontsize=10,
                   color=:mediumturquoise, size=(500,350), bins = 25,
                   xlim=((25, 125)),
                   ylabel="Relative frequency", 
                   title="gRNA frequency distribution")
  0.001918 seconds (7.75 k allocations: 329.570 KiB)

Any advice?

It seems that when I create the histogram object outside of the .jmd file and instead send it to the .jmd file using WEAVE_ARGS it works fine.

EDIT: I spoke to soon, it just seems to randomly work fine and other times not, perhaps its due to the .jmd file or the image file being open somewhere and not able to close.

Apparently this is a known bug reported here, including a workaround: https://github.com/JunoLab/Weave.jl/issues/436.

ENV["GKSwstype"]="nul"
weave("00.jl", cache=:off, out_path="output/")
ENV["GKSwstype"]="gksqt"
1 Like