Skip to content

Commit 82c5cfc

Browse files
Capture more error info when workers fail to start up (#265)
1 parent 7fd5636 commit 82c5cfc

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Fix missing display maths output in Typst. Works around inconsistency in handling of markdown math syntax between Quarto output formats [#262]
13+
- Print out better errors when worker `julia` processes fail to start [#265]
1314

1415
## [v0.13.1] - 2025-02-18
1516

@@ -383,3 +384,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
383384
[#255]: https://github.com/PumasAI/QuartoNotebookRunner.jl/issues/255
384385
[#257]: https://github.com/PumasAI/QuartoNotebookRunner.jl/issues/257
385386
[#262]: https://github.com/PumasAI/QuartoNotebookRunner.jl/issues/262
387+
[#265]: https://github.com/PumasAI/QuartoNotebookRunner.jl/issues/265

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
88
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
99
CommonMark = "a80b9123-70ca-4bc0-993e-6e3bcb318db6"
1010
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
11+
IOCapture = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
1112
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1213
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
1314
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
@@ -29,6 +30,7 @@ BSON = "0.3"
2930
Base64 = "1.6"
3031
CommonMark = "0.8"
3132
Compat = "4"
33+
IOCapture = "0.2"
3234
InteractiveUtils = "1.6"
3335
IterTools = "1"
3436
JSON3 = "1"

src/Malt.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Malt
88
import ..QuartoNotebookRunner: UserError
99

1010
import BSON
11+
import IOCapture
1112
import Pkg
1213
import TOML
1314
using Sockets: Sockets
@@ -129,6 +130,17 @@ mutable struct Worker <: AbstractWorker
129130

130131
err_output = read(errors_log_file, String)
131132
if isnothing(manifest_error)
133+
empty_result = IOCapture.capture(; rethrow = InterruptException) do
134+
run(_get_worker_cmd(; exe, env, exeflags, file = String(empty_file)))
135+
end
136+
if empty_result.error
137+
message = """
138+
Failed to start worker process.
139+
140+
$(empty_result.output)
141+
"""
142+
error(message)
143+
end
132144
# Generic error reporting when we've not received a port
133145
# number from the worker. This just prints out the error
134146
# message and stacktrace that have come from the worker
@@ -367,15 +379,16 @@ end
367379

368380
# The entire `src` dir should be relocatable, so that worker.jl can include("MsgType.jl").
369381
const startup_file = RelocatableFolders.@path joinpath(@__DIR__, "startup.jl")
382+
const empty_file = RelocatableFolders.@path joinpath(@__DIR__, "empty.jl")
370383
const worker_package = RelocatableFolders.@path joinpath(@__DIR__, "QuartoNotebookWorker")
371384

372-
function _get_worker_cmd(; exe, env, exeflags)
385+
function _get_worker_cmd(; exe, env, exeflags, file = String(startup_file))
373386
defaults = Dict(
374387
"OPENBLAS_NUM_THREADS" => "1",
375388
"QUARTONOTEBOOKWORKER_PACKAGE" => String(worker_package),
376389
)
377390
env = vcat(Base.byteenv(defaults), Base.byteenv(env))
378-
return addenv(`$exe --startup-file=no $exeflags $(String(startup_file))`, env)
391+
return addenv(`$exe --startup-file=no $exeflags $file`, env)
379392
end
380393

381394
# Checks whether a `julia` command (including it's program flags and juliaup

src/empty.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/server.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,16 @@ function _julia_exe(exeflags)
5151
if all(!isnothing, Sys.which.(("juliaup", "julia")))
5252
indices = findall(startswith("+"), exeflags)
5353
if isempty(indices)
54-
# Use the default `julia` channel set for `juliaup`.
55-
return `julia`, exeflags
54+
quarto_julia = get(ENV, "QUARTO_JULIA", nothing)
55+
if isnothing(quarto_julia)
56+
# Use the default `julia` channel set for `juliaup`.
57+
return `julia`, exeflags
58+
else
59+
# Use the `julia` binary that was specified in the environment
60+
# variable that can be passed to `quarto` to pick the server
61+
# process `julia` to use.
62+
return `$quarto_julia`, exeflags
63+
end
5664
else
5765
# Pull out the channel from the exeflags. Since we merge in
5866
# exeflags from the `QUARTONOTEBOOKRUNNER_EXEFLAGS` environment

0 commit comments

Comments
 (0)