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

quarto render fails with relative path and knitr-based notebook. #9478

Closed
gordonwoodhull opened this issue Apr 24, 2024 · 4 comments · Fixed by #9609
Closed

quarto render fails with relative path and knitr-based notebook. #9478

gordonwoodhull opened this issue Apr 24, 2024 · 4 comments · Fixed by #9609
Assignees
Labels
bug Something isn't working knitr
Milestone

Comments

@gordonwoodhull
Copy link
Contributor

Bug description

When producing multiple outputs for side-by-side comparison, I prefer to run my utils/render-all-formats.ts script from a parent directory.

However, I'm currently unable to run a knitr-based notebook using a relative path.

The error is

Error in rmarkdown:::abs_path(input) : 
  The file 'baz/foo.qmd' does not exist.

but the file does exist, and running rmarkdown:::abs_path('baz/foo.qmd') directly in R is okay.

I only somewhat regret bisecting this over a slow internet connection. I think it will be no surprise that the bad commit seems to be "create ProjectContext in single-file mode to guarantee engine and target caching" a28ac25. Two big steps forward and a baby step back!

Steps to reproduce

Minimal repro: put any knitr-based notebook in a subdirectory, e.g. this baz/foo.qmd

---
title: "relative path"
---

```{r}
print(1+1)
```

Then run

quarto render baz/foo.qmd

I'm not sure how to write a regression test for this, since it's about invocation rather than the content of the example.

Expected behavior

It should render the qmd inside the directory.

Actual behavior

Error in rmarkdown:::abs_path(input) : 
  The file 'baz/foo.qmd' does not exist.
Calls: .main -> execute -> setwd -> dirname -> <Anonymous>
Execution halted
ERROR: Error
    at renderFiles (file:///Users/gordon/src/quarto-cli/src/command/render/render-files.ts:350:23)
    at eventLoopTick (ext:core/01_core.js:153:7)
    at async render (file:///Users/gordon/src/quarto-cli/src/command/render/render-shared.ts:102:18)
    at async Command.actionHandler (file:///Users/gordon/src/quarto-cli/src/command/render/cmd.ts:248:26)
    at async Command.execute (file:///Users/gordon/src/quarto-cli/src/vendor/deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1948:7)
    at async Command.parseCommand (file:///Users/gordon/src/quarto-cli/src/vendor/deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1780:14)
    at async quarto (file:///Users/gordon/src/quarto-cli/src/quarto.ts:156:3)
    at async file:///Users/gordon/src/quarto-cli/src/quarto.ts:170:5
    at async mainRunner (file:///Users/gordon/src/quarto-cli/src/core/main.ts:35:5)
    at async file:///Users/gordon/src/quarto-cli/src/quarto.ts:160:3

Your environment

MacOS Sonoma 14.4.1

Quarto check output

Quarto 99.9.9
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.13: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
fatal: not a git repository (or any of the parent directories): .git
      Path: /Users/gordon/src/quarto-cli/package/dist/bin

[✓] Checking tools....................OK
      TinyTeX: v2024.04
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/gordon/Library/TinyTeX/bin/universal-darwin
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.9.6
      Path: /Library/Developer/CommandLineTools/usr/bin/python3
      Jupyter: 5.7.1
      Kernels: python3

(|) Checking Jupyter engine render..../Users/gordon/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.2
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
      knitr: 1.45
      rmarkdown: 2.25

[✓] Checking Knitr engine render......OK

@gordonwoodhull gordonwoodhull added the bug Something isn't working label Apr 24, 2024
@gordonwoodhull gordonwoodhull changed the title knitr won't render with relative path quarto run fails with relative path and knitr-based notebook. Apr 24, 2024
@mcanouil mcanouil added the knitr label Apr 25, 2024
@cscheid cscheid self-assigned this Apr 25, 2024
@cscheid cscheid added this to the v1.5 milestone Apr 25, 2024
@cscheid
Copy link
Collaborator

cscheid commented Apr 25, 2024

This is a really bad one 😬.

@cscheid
Copy link
Collaborator

cscheid commented Apr 25, 2024

More information

Adding an empty _quarto.yml file to the same directory is a workaround.

@cscheid cscheid changed the title quarto run fails with relative path and knitr-based notebook. quarto render fails with relative path and knitr-based notebook. May 3, 2024
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented May 3, 2024

If only I had remembered this hint before my demo!

Yes, adding empty _quarto.yml to the root works great as a workaround to get quarto run to work with relative paths.

@mine-cetinkaya-rundel
Copy link

I just ran into this as well. Using the Render button in RStudio worked but quarto_render() or quarto render didn't and required adding the empty _quarto.yml file.

In my case I was also trying to run these in a different directory in a withr::with_dir() call, which wasn't helped by adding an empty _quarto.yml file in the root of the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working knitr
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants