# Help with Weave.jl

**URL:** https://discourse.julialang.org/t/help-with-weave-jl/97177
**Category:** General Usage
**Tags:** weave
**Created:** [April 6, 2023, 1:35pm UTC](https://discourse.julialang.org/t/help-with-weave-jl/97177 "2023-04-06T13:35:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [April 6, 2023, 1:35pm UTC](https://discourse.julialang.org/t/help-with-weave-jl/97177/1 "2023-04-06T13:35:43Z")

</div>

I’m trying to test out Weave.jl and it works fine when converting to .html, but I can’t get it to convert to .pdf. My project directory looks like this:

```julia
WeaveTest/
-src/
--main.jl
--test.jmd

```

In `main.jl`, I am calling `weave(raw"C:\Users\mthel\Julia\WeaveTest\src\test.jmd", doctype="md2pdf")`

and it produces this error:

```julia
ERROR: IOError: could not spawn `xelatex -shell-escape -halt-on-error test.tex`: no such file or directory (ENOENT)
Stacktrace:
  [1] _spawn_primitive(file::String, cmd::Cmd, stdio::Vector{Union{RawFD, Base.Libc.WindowsRawSocket, IO}})
    @ Base .\process.jl:128
  [2] #724
    @ .\process.jl:139 [inlined]
  [3] setup_stdios(f::Base.var"#724#725"{Cmd}, stdios::Vector{Union{RawFD, Base.Libc.WindowsRawSocket, IO}})
    @ Base .\process.jl:223
  [4] _spawn
    @ .\process.jl:138 [inlined]
  [5] run(::Cmd; wait::Bool)
    @ Base .\process.jl:479
  [6] run
    @ .\process.jl:477 [inlined]
  [7] write_doc(docformat::Weave.LaTeX2PDF, doc::Weave.WeaveDoc, rendered::String, out_path::String)
    @ Weave C:\Users\mthel\.julia\packages\Weave\f7Ly3\src\writer\latex.jl:10
  [8] write_doc(doc::Weave.WeaveDoc, rendered::String, out_path::String)
    @ Weave C:\Users\mthel\.julia\packages\Weave\f7Ly3\src\writer\writer.jl:2
  [9] weave(source::String; doctype::String, informat::Nothing, out_path::Symbol, args::Dict{Any, Any}, mod::Nothing, fig_path::Nothing, fig_ext::Nothing, cache_path::String, cache::Symbol, template::Nothing, css::Nothing, highlight_theme::Nothing, pandoc_options::Vector{String}, latex_cmd::Vector{String}, keep_unicode::Bool)
    @ Weave C:\Users\mthel\.julia\packages\Weave\f7Ly3\src\Weave.jl:226
 [10] top-level scope
    @ c:\Users\mthel\Julia\WeaveTest\src\main.jl:3

```

After calling `weave`, I get a `test.tex` file and if I open a console and manually input the command: `xelatex -shell-escape -halt-on-error test.tex`, it produces the .pdf as expected.

---

<div class="post-metadata">

### Author: ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)
#### Post date: [April 6, 2023, 2:08pm UTC](https://discourse.julialang.org/t/help-with-weave-jl/97177/2 "2023-04-06T14:08:02Z")

</div>

I think what you are doing should work, and this is likely a bug. I have only used Weave a handful of times, but this works for me. Maybe setting the `out_path` keyword argument will help xelatex find the file.

```julia
    weave(
        normpath(@ __DIR__ , "..", "src", "KD232_nomenclature.jl");
        doctype = "md2pdf",
        out_path = normpath(@ __DIR__ , "..", "KD232_nomenclature.pdf"),
    )
    rm(normpath(@ __DIR__ , "..", "KD232_nomenclature.aux"))
    rm(normpath(@ __DIR__ , "..", "KD232_nomenclature.log"))
    rm(normpath(@ __DIR__ , "..", "KD232_nomenclature.out"))
    rm(normpath(@ __DIR__ , "..", "KD232_nomenclature.tex"))

```

There are four intermediate files that are created between markdown and pdf, so I just delete them afterward.

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [April 6, 2023, 2:20pm UTC](https://discourse.julialang.org/t/help-with-weave-jl/97177/3 "2023-04-06T14:20:52Z")

</div>

So it looks like something weird is going on and Julia can’t seem to execute the `xelatex` command. I can do `run(weather_cli --help)` (where weather\_cli is a command line utility I have installed) and it successfully executes that command and I see the output in my Julia REPL, but if I do `run(xelatex --help)` I get the error: `ERROR: IOError: could not spawn `xelatex --help`: no such file or directory (ENOENT)`. This is strange because, as I mentioned, I can open a console and run `xelatex` without any problems…

EDIT: If I specify the full path to the `xelatex` executable, it works:

```julia
run(`$(normpath("C:\\Program Files\\MiKTeX\\miktex\\bin\\x64\\xelatex.exe")) -shell-escape -halt-on-error test.tex`)

```

---

<div class="post-metadata">

### Author: ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)
#### Post date: [April 6, 2023, 2:33pm UTC](https://discourse.julialang.org/t/help-with-weave-jl/97177/4 "2023-04-06T14:33:04Z")

</div>

I just confirmed that I can convert to pdf with the latest version of Weave even without the `out_path` argument. `run(xelatex --help)` works as expected in my Julia REPL, so your issue is definitely related to that. I’m don’t know enough to help you further. 🫤

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [April 6, 2023, 2:42pm UTC](https://discourse.julialang.org/t/help-with-weave-jl/97177/5 "2023-04-06T14:42:51Z")

</div>

So I just needed to restart my computer 😆. When all else fails, unplug it, and plug it back in!
