-
Notifications
You must be signed in to change notification settings - Fork 331
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
Embeded chunks do not respect the "execute-dir: project" setting #9649
Comments
Thanks for the report I can reproduce this on Here is a reproducible example without requiring to use R to create it: quarto create project website quarto-cli-9649 quarto-cli-9649
cd quarto-cli-9649
mkdir assets
echo -e "```{r}\n#| label: embedme\nreadLines("data.txt")\n```\n" > assets/_embed.qmd
echo "1" > data.txt
echo "{{< embed assets/_embed.qmd#embedme >}}" >> index.qmd
awk 'NR==3{print " execute-dir: project"}1' _quarto.yml > temp && mv temp _quarto.yml Also as a directory in https://github.com/mcanouil/quarto-issues-experiments/tree/main/quarto-cli-9649 |
@mcanouil your example above is missing the modification of It seems indeed that
quarto-cli/src/command/render/project.ts Lines 327 to 340 in b35914c
Used at file rendering quarto-cli/src/command/render/project.ts Lines 390 to 400 in b35914c
Those options are used when building context quarto-cli/src/command/render/render-files.ts Lines 431 to 439 in b35914c
context is passed to execution quarto-cli/src/command/render/render-files.ts Lines 591 to 596 in b35914c
where flags.executeDir is used to modify the cwd for executionquarto-cli/src/command/render/render-files.ts Line 223 in b35914c
This is for usual rendering. For embed file rendering, there is a special rendering process, with a specific quarto-cli/src/render/notebook/notebook-contributor-qmd.ts Lines 121 to 142 in b35914c
This function currently does not account for This is the reason of the issue. It is part of all the rendering improvements we need to do for Current workaroundNow that we understand the cause, we can find a workaround to use while this is being resolved. I would advice: don't rely on relative path to project context to load data. This is a long standing advice in R Markdown ecosystem already, and package like here help for this. Example ```{r}
#| label: embedme
readLines(xfun::from_root('data.txt', root = Sys.getenv("QUARTO_PROJECT_DIR")))
``` Also, don't use As an example for R here package, the new mechanism to define project root does not even need Quarto information ```{r}
#| include: false
here::i_am("assets/embed.qmd")
```
```{r}
#| label: embedme
readLines(here::here('data.txt'))
``` See the doc of the package for more on its usage. Anyhow, we'll solve this when we will tackle embed improvement |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Thanks for getting on this so quick and for the temporary workaround.!I can confirm that the embedding works with the This workaround works, but it adds friction during development. I also find it occasionally problematic, because here::here returns absolute paths that are OS and user specific - for some applications, the file path is stored in created objects. This makes portability problematic and can also be undersired to share personal system configurations. |
Thanks for the feedback. Rest assured this will be fixed - it is among a set of issues with embed that we'll probably tackle for 1.6. Thanks for your patience. |
Bug description
I have a quarto project, in which I have set the "execute-dir: project" in the yml file. This is because I have data files in one folder in the project dir, and quarto notebooks in a docs folder. When an individual notebook loads data files it works. However, if I embed a chunk from such a notebook into another, suddenly I get an error that the file cannot be found. Seems like rendering of notebooks to embed them does not respect the execture-dir: project setting.
Steps to reproduce
Created on 2024-05-13 with reprex v2.1.0
You can see from the output that the
inner\file.qmd
is rendered succesfully by itself. However, when it is rendered to create and embeded chunk, it fails. This is not due to usingquarto::quarto_render()
- the same happens with the CLI, but the reprex does not show the output...Expected behavior
Rendering of notebooks via embedings (https://quarto.org/docs/authoring/notebook-embed.html#overview) should respect the _quarto.yml options
Actual behavior
it does not respect the execute-dir: project option
Your environment
Quarto check output
Quarto 1.4.553
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.1.11: OK
Dart Sass version 1.69.5: OK
Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.4.553
Path: /Applications/quarto/bin
[✓] Checking tools....................OK
TinyTeX: (not installed)
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Tex: (not detected)
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.12.1 (Conda)
Path: /opt/miniconda3/bin/python
Jupyter: 5.5.0
Kernels: ir, python3
[✓] Checking Jupyter engine render....OK
[✓] Checking R installation...........OK
Version: 4.3.3
Path: /opt/homebrew/Cellar/r/4.3.3/lib/R
LibPaths:
- /opt/homebrew/lib/R/4.3/site-library
- /opt/homebrew/Cellar/r/4.3.3/lib/R/library
knitr: 1.46
rmarkdown: 2.26
[✓] Checking Knitr engine render......OK
The text was updated successfully, but these errors were encountered: