Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Invalid cross-device link (os error 18), rename ... -> ...pdf #35

Closed
kapsner opened this issue Aug 3, 2022 · 3 comments
Closed

Comments

@kapsner
Copy link

kapsner commented Aug 3, 2022

When running quarto::quarto_render inside a docker container to render a PDF-document I get the following error:

....

|......................................................................| 100%
  ordinary text without R code


output file: report.knit.md

pandoc --output report.tex
  to: latex
  standalone: true
  pdf-engine: xelatex
  variables:
    graphics: true
    tables: true
  default-image-extension: pdf

metadata
  block-headings: true
  title: My Report
  date: '`r format(Sys.Date(), ''%d-%m-%Y'')`'
  documentclass: article

running xelatex - 1
  This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

running xelatex - 2
  This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode


ERROR: Invalid cross-device link (os error 18), rename 'report.pdf' -> '/opt/output/report.pdf'
Error in `processx::run(quarto_bin, args, echo = TRUE)`:
! System command 'quarto' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Backtrace:
1. quarto::quarto_render(input = "report.qmd", output_format = "pdf", …
2. processx::run(quarto_bin, args, echo = TRUE)
3. processx:::throw(new_process_error(res, call = sys.call(), echo = echo, …
Execution halted

It seems as if something is wrong when trying to place the final pdf report in the output folder. Any ideas to solve the issue would be highly appreciated! Thanks in advance.

Edit:
I do not fully understand the syntax, however, could it be that this part in quarto's source code somehow related because of renaming the file instead of moving it (as the call to Deno.renameSync suggests)? (and: although affecting python , could this be related as well: core-api/python-client#176 ?)

@kapsner
Copy link
Author

kapsner commented Aug 4, 2022

Some additional information:

The docker-container is based on rocker/verse:4.2.1 with WORKDIR set to the dir /opt/R, which contains the report.qmd and a render_report.R-script, which is executed by the container's entrypoint:

docker run -it --rm  \
    -v //d/workspace/results_output:/opt/output \
    render_report_container:latest \
    Rscript render_report.R

A volume is mounted for collecting the resulting PDF-report.

The render_report.R looks as follows:

base_dir <- "/opt/output"

quarto::quarto_render(
  input = "report.qmd",
  output_format = "pdf",
  output_file = file.path(base_dir, "report.pdf")
)

Executing this script results in the error described above.

However, after experimenting a bit, I discovered that changing the R-script as follows indeed produces the desired result and the PDF document successfully appears in the mounted volume.

base_dir <- "/opt/output"

quarto::quarto_render(
  input = "report.qmd",
  output_format = "pdf",
  output_file = "report.pdf"
)

file.copy(
  from = "report.pdf",
  to = base_dir
)

Thus, leaving the copying of the file to R works perfectly opposed to having the file copied by quarto.

@cderv
Copy link
Collaborator

cderv commented Jan 10, 2023

Sorry for the delay here. This is the issue thread of the R Package quarto, and we are not thoroughly following as we do for the main project at quarto-dev/quarto-cli

This error usually comes with a step of moving a file by renaming it cross mount. In some OS this is not possible and the file should be copied and renamed and not moved. This is why your experiment by copying the file afterwards works. Probably using file.rename or other moving function in R (not copying) would fail too.

Do you know if this is still an issue with last version of Quarto ?
Seems like the line is still here
https://github.com/quarto-dev/quarto-cli/blob/2bdf5e8ab4dd35f52f0ee73b74209ec7fdfcae31/src/command/render/output-tex.ts#L84

I would say this is related also to quarto-dev/quarto-cli#2671 which is about output directory but same for output file.

I'll comment there

@cderv
Copy link
Collaborator

cderv commented Jan 10, 2023

I have commented in the other issue so I am closing this one here.

Thank you for the report!

@cderv cderv closed this as completed Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants