JuliaPluto / PlutoPDF.jl

Export Pluto notebooks to PDF from the command line
MIT License
35 stars 1 forks source link

Pipeline error #18

Open dpo opened 1 month ago

dpo commented 1 month ago
❯ wget https://featured.plutojl.org/basic/Pluto%20for%20scientists.jl && mv "Pluto for scientists.jl" notebook.jl

❯ cat pluto_to_pdf.jl
import PlutoPDF
PlutoPDF.pluto_to_pdf("notebook.jl")

❯ julia pluto_to_pdf.jl
[ Info: Running notebook...
┌ Warning: The active manifest file at `/private/var/folders/0w/gr6q1p614svb9p0gfmlcfjjr0000gn/T/jl_UQYNJ0/Manifest.toml` has an old format that is being maintained.
│ To update to the new format, which is supported by Julia versions ≥ 1.6.2, run `import Pkg; Pkg.upgrade_manifest()` which will upgrade the format without re-resolving.
│ To then record the julia version re-resolve with `Pkg.resolve()` and if there are resolve conflicts consider `Pkg.update()`.
└ @ Pkg.Types ~/.julia/juliaup/julia-1.10.4+0.x64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/manifest.jl:318
    Updating registry at `~/.julia/registries/General.toml`
┌ Warning: The active manifest file is an older format with no julia version entry. Dependencies may have been resolved with a different julia version.
└ @ /private/var/folders/0w/gr6q1p614svb9p0gfmlcfjjr0000gn/T/jl_UQYNJ0/Manifest.toml:0
[ Info: Generating pdf...
[ Info: PlutoPDF: Running npm install in scratch space...
10.5.0

up to date, audited 123 packages in 1s

11 packages are looking for funding
  run `npm fund` for details

5 high severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

  Degraded performance warning:
  Launching Chrome on Mac Silicon (arm64) from an x64 Node installation results in
  Rosetta translating the Chrome binary, even if Chrome is already arm64. This would
  result in huge performance issues. To resolve this, you must run Puppeteer with
  a version of Node built for arm64.
Initiated headless browser
file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/util/Deferred.js:56
            this.#timeoutError = new TimeoutError(opts.message);
                                 ^

TimeoutError: Navigation timeout of 30000 ms exceeded
    at new Deferred (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/util/Deferred.js:56:34)
    at Deferred.create (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/util/Deferred.js:18:16)
    at new LifecycleWatcher (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/LifecycleWatcher.js:62:46)
    at CdpFrame.goto (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Frame.js:132:29)
    at CdpFrame.<anonymous> (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/util/decorators.js:94:27)
    at CdpPage.goto (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js:563:43)
    at pdf (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/export.js:18:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/bin.js:16:1

Node.js v20.12.2
ERROR: LoadError: failed process: Process(setenv(`/Users/dpo/.julia/artifacts/7cb314205de4825730e5c6c3e356bf5d298dcb77/bin/node /Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/bin.js /var/folders/0w/gr6q1p614svb9p0gfmlcfjjr0000gn/T/jl_jWvSdA1WBC.html /private/tmp/book/notebook.pdf '{"format":"A4","margin":{"top":"30mm","right":"15mm","bottom":"30mm","left":"10mm"},"printBackground":true,"displayHeaderFooter":false}' '' '{"outputOnly":false,"scale":2}'`,["XPC_FLAGS=0x0", "P9K_SSH=0", "PATH=/Users/dpo/.julia/artifacts/7cb314205de4825730e5c6c3e356bf5d298dcb77/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/usr/local/MacGPG2/bin:/Library/TeX/texbin:/Applications/quarto/bin:/Users/dpo/local/solvers/knitro/knitro-13.0.1-MacOS-M1/knitroampl:/Users/dpo/perl5/bin:/opt/homebrew/opt/openjdk/bin:/Users/dpo/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/opt/fzf/bin", "EDITOR=lvim", "LATEX_STYLES=/Users/dpo/dev/latex/latex-styles", "XPC_SERVICE_NAME=0", "HOMEBREW_PREFIX=/opt/homebrew", "_P9K_TTY=/dev/ttys015", "DYLD_FALLBACK_LIBRARY_PATH=/Users/dpo/.julia/juliaup/julia-1.10.4+0.x64.apple.darwin14/bin/../lib/julia:/Users/dpo/.julia/juliaup/julia-1.10.4+0.x64.apple.darwin14/bin/../lib:/Users/dpo/lib:/usr/local/lib:/lib:/usr/lib", "PERL_MM_OPT=INSTALL_BASE=/Users/dpo/perl5"  …  "BIBINPUTS=.:/Users/dpo/dev/latex/latex-styles/share::", "P9K_TTY=old", "WEZTERM_CONFIG_DIR=/Users/dpo/.config/wezterm", "PERL_MB_OPT=--install_base \"/Users/dpo/perl5\"", "WEZTERM_CONFIG_FILE=/Users/dpo/.config/wezterm/wezterm.lua", "HOME=/Users/dpo", "TERM=xterm-256color", "WEZTERM_PANE=16", "OPENBLAS_MAIN_FREE=1", "COLORTERM=truecolor"]), ProcessExited(1)) [1]

Stacktrace:
 [1] pipeline_error
   @ ./process.jl:565 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base ./process.jl:480
 [3] run
   @ ./process.jl:477 [inlined]
 [4] html_to_pdf(html_path::String, output_path::String, screenshot_dir_path::Nothing; options::@NamedTuple{format::String, margin::@NamedTuple{top::String, right::String, bottom::String, left::String}, printBackground::Bool, displayHeaderFooter::Bool}, screenshot_options::@NamedTuple{outputOnly::Bool, scale::Int64}, open::Bool, console_output::Bool)
   @ PlutoPDF ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:75
 [5] html_to_pdf
   @ ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:49 [inlined]
 [6] pluto_to_pdf(notebook_path::String, output_path::Nothing, screenshot_dir_path::Nothing; kwargs::@Kwargs{})
   @ PlutoPDF ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:129
 [7] pluto_to_pdf
   @ ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:108 [inlined]
 [8] pluto_to_pdf(notebook_path::String)
   @ PlutoPDF ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:108
 [9] top-level scope
   @ /private/tmp/book/pluto_to_pdf.jl:2
in expression starting at /private/tmp/book/pluto_to_pdf.jl:2
fonsp commented 1 month ago

Weird! What Julia version do you have? Do you have the armr64 or x86 version of Julia?

dpo commented 1 month ago

I'm using Julia 1.10.4. I tried both x86 and aarch64. The error above is with the x86 version. On aarch64, I get

❯ julia pluto_to_pdf.jl                                                                                                                                                                                                            07:44:12
[ Info: Running notebook...
┌ Warning: The active manifest file at `/private/var/folders/0w/gr6q1p614svb9p0gfmlcfjjr0000gn/T/jl_4GwZ0q/Manifest.toml` has an old format that is being maintained.
│ To update to the new format, which is supported by Julia versions ≥ 1.6.2, run `import Pkg; Pkg.upgrade_manifest()` which will upgrade the format without re-resolving.
│ To then record the julia version re-resolve with `Pkg.resolve()` and if there are resolve conflicts consider `Pkg.update()`.
└ @ Pkg.Types ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/manifest.jl:318
    Updating registry at `~/.julia/registries/General.toml`
┌ Warning: The active manifest file is an older format with no julia version entry. Dependencies may have been resolved with a different julia version.
└ @ /private/var/folders/0w/gr6q1p614svb9p0gfmlcfjjr0000gn/T/jl_4GwZ0q/Manifest.toml:0
[ Info: Generating pdf...
[ Info: PlutoPDF: Running npm install in scratch space...
10.5.0

up to date, audited 123 packages in 705ms

11 packages are looking for funding
  run `npm fund` for details

5 high severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:259
                    throw new Error(`Could not find Chrome (ver. ${this.puppeteer.browserRevision}). This can occur if either\n` +
                          ^

Error: Could not find Chrome (ver. 121.0.6167.85). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or
 2. your cache path is incorrectly configured (which is: /Users/dpo/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at ChromeLauncher.resolveExecutablePath (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:259:27)
    at ChromeLauncher.executablePath (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:190:25)
    at ChromeLauncher.computeLaunchArguments (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:83:37)
    at async ChromeLauncher.launch (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:44:28)
    at async pdf (file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/export.js:14:21)
    at async file:///Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/bin.js:16:1

Node.js v20.12.2
ERROR: LoadError: failed process: Process(setenv(`/Users/dpo/.julia/artifacts/34a516c9d97d925f9ae668de15ecaa6eeeb8df32/bin/node /Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6/build_dir3/bin.js /var/folders/0w/gr6q1p614svb9p0gfmlcfjjr0000gn/T/jl_VM1ktKPO9M.html /private/tmp/notebook.pdf '{"format":"A4","margin":{"top":"30mm","right":"15mm","bottom":"30mm","left":"10mm"},"printBackground":true,"displayHeaderFooter":false}' '' '{"outputOnly":false,"scale":2}'`,["XPC_FLAGS=0x0", "P9K_SSH=0", "PATH=/Users/dpo/.julia/artifacts/34a516c9d97d925f9ae668de15ecaa6eeeb8df32/bin:/Users/dpo/.gem/ruby/3.1.3/bin:/Users/dpo/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0/bin:/Users/dpo/.rubies/ruby-3.1.3/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/usr/local/MacGPG2/bin:/Library/TeX/texbin:/Applications/quarto/bin:/Users/dpo/local/solvers/knitro/knitro-13.0.1-MacOS-M1/knitroampl:/Users/dpo/perl5/bin:/opt/homebrew/opt/openjdk/bin:/Users/dpo/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/opt/fzf/bin", "EDITOR=lvim", "LATEX_STYLES=/Users/dpo/dev/latex/latex-styles", "XPC_SERVICE_NAME=0", "HOMEBREW_PREFIX=/opt/homebrew", "_P9K_TTY=/dev/ttys012", "DYLD_FALLBACK_LIBRARY_PATH=/Users/dpo/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/bin/../lib/julia:/Users/dpo/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/bin/../lib:/Users/dpo/lib:/usr/local/lib:/lib:/usr/lib", "PERL_MM_OPT=INSTALL_BASE=/Users/dpo/perl5"  …  "P9K_TTY=old", "GEM_HOME=/Users/dpo/.gem/ruby/3.1.3", "WEZTERM_CONFIG_DIR=/Users/dpo/.config/wezterm", "PERL_MB_OPT=--install_base \"/Users/dpo/perl5\"", "WEZTERM_CONFIG_FILE=/Users/dpo/.config/wezterm/wezterm.lua", "HOME=/Users/dpo", "TERM=xterm-256color", "WEZTERM_PANE=14", "OPENBLAS_MAIN_FREE=1", "COLORTERM=truecolor"]), ProcessExited(1)) [1]

Stacktrace:
 [1] pipeline_error
   @ ./process.jl:565 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base ./process.jl:480
 [3] run
   @ ./process.jl:477 [inlined]
 [4] html_to_pdf(html_path::String, output_path::String, screenshot_dir_path::Nothing; options::@NamedTuple{format::String, margin::@NamedTuple{top::String, right::String, bottom::String, left::String}, printBackground::Bool, displayHeaderFooter::Bool}, screenshot_options::@NamedTuple{outputOnly::Bool, scale::Int64}, open::Bool, console_output::Bool)
   @ PlutoPDF ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:75
 [5] html_to_pdf
   @ ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:49 [inlined]
 [6] pluto_to_pdf(notebook_path::String, output_path::Nothing, screenshot_dir_path::Nothing; kwargs::@Kwargs{})
   @ PlutoPDF ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:129
 [7] pluto_to_pdf
   @ ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:108 [inlined]
 [8] pluto_to_pdf(notebook_path::String)
   @ PlutoPDF ~/.julia/packages/PlutoPDF/S8wOa/src/PlutoPDF.jl:108
 [9] top-level scope
   @ /private/tmp/pluto_to_pdf.jl:2
in expression starting at /private/tmp/pluto_to_pdf.jl:2

Are we supposed to install other tools manually in order for PlutoPDF to work?

fonsp commented 1 month ago

Could you delete /Users/dpo/.julia/scratchspaces/6eb38059-8c05-41f7-8871-5e7e2697ace6 (or just all scratch spaces with /Users/dpo/.julia/scratchspaces/ if you don't mind) and try again? Julia 1.10.4 with x86 should work.

fonsp commented 1 month ago

@dpo Can you check if https://github.com/JuliaPluto/PlutoPDF.jl/pull/19 fixes your issue?