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

File in subdirectory not found #11360

Open
mutlusun opened this issue Nov 11, 2024 · 9 comments
Open

File in subdirectory not found #11360

mutlusun opened this issue Nov 11, 2024 · 9 comments
Assignees
Labels
backport bug Something isn't working inspect
Milestone

Comments

@mutlusun
Copy link

mutlusun commented Nov 11, 2024

Bug description

I recently updated to quarto version 1.5.57 from 1.5.35. After updating, quarto inspect is no longer able to find a document file in a subdirectory. Ironically, quarto render works fine. I could bisect that this problem appeard between v1.5.51 and v1.5.57. I assume this commit is the culprit.

Please see this MR as a reference where the issue appeared first.

Steps to reproduce

Create these files:

Main file:

---
title: main
format:
  html:
    default
---

{{< include "subdir/text2.qmd" >}}

Text 2 (in ./subdir/):

# Second File

Some text here.

{{< include "subdir/b/text3.qmd" >}}

Text 3 (in ./subdir/b/):

# Third File

Some text here.

Now, run quarto inspect.

Expected behavior

quarto inspect outputs the desired information.

Actual behavior

quarto inspect fails with the following message:

ERROR: NotFound: No such file or directory (os error 2): readfile '/home/***/tmp/tarche-test/subdir/subdir/b/text3.qmd'
Path: /home/***/tmp/tarche-test/subdir/subdir/b/text3.qmd

Stack trace:
Path: /home/***/tmp/tarche-test/subdir/subdir/b/text3.qmd
    at readTextFileSync (ext:deno_fs/30_fs.js:859:10)
    at Object.Deno.readTextFileSync (file:///tmp/.mount_quartodxyAMD/usr/bin/quarto.js:5047:25)
    at mappedStringFromFile (file:///tmp/.mount_quartodxyAMD/usr/bin/quarto.js:19592:24)
    at Object.markdownForFile (file:///tmp/.mount_quartodxyAMD/usr/bin/quarto.js:40863:32)
    at mdForFile (file:///tmp/.mount_quartodxyAMD/usr/bin/quarto.js:40283:29)
    at inner (file:///tmp/.mount_quartodxyAMD/usr/bin/quarto.js:40322:67)
    at inner (file:///tmp/.mount_quartodxyAMD/usr/bin/quarto.js:40322:23)
    at async projectResolveCodeCellsForFile (file:///tmp/.mount_quartodxyAMD/usr/bin/quarto.js:40342:5)
    at async inspectConfig (file:///tmp/.mount_quartodxyAMD/usr/bin/quarto.js:101478:13)
    at async Command.actionHandler (file:///tmp/.mount_quartodxyAMD/usr/bin/quarto.js:101515:20)

quarto render runs fine. Even after removing the subdir in the include of text3.qmd, the command fails.

Your environment

  • OS: Linux

Quarto check output

Quarto 1.5.57
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: 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: 1.5.57
      Path: /tmp/.mount_quartoWCrNeu/usr/bin

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

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /usr/bin
      Version: 2023

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.7
      Path: /usr/bin/python3
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

[✓] Checking R installation...........OK
      Version: 4.4.1
      Path: /usr/lib64/R
      LibPaths:
        - /home/***/.local/share/R/R.library
        - /usr/lib64/R/library
        - /usr/share/R/library
      knitr: 1.48
      rmarkdown: 2.26

[✓] Checking Knitr engine render......OK
@mutlusun mutlusun added the bug Something isn't working label Nov 11, 2024
@mcanouil
Copy link
Collaborator

Could you try using the 1.6 pre-release?

@mutlusun
Copy link
Author

It happens also with 1.6.33

@mcanouil
Copy link
Collaborator

mcanouil commented Nov 11, 2024

Thanks.

output_format: html this is not Quarto.

Note that the main issue is that you use relative (to calling document) paths since you are not in a Quarto project _quarto.yml.

Add _quarto.yml and add leading / to tell Quarto the paths are relatives to the root.

I'm not sure this is really a bug, look at the path from the error message.

@mutlusun
Copy link
Author

Ah, thanks for noticing this. However, quarto inspect still fails even using the following header (I will edit the first message accordingly):

---
title: main
format:
  html:
    default
---

Quarto also fails when prepending ./ to all paths to make clear that they are relative. I really thinks that an issue because of the following two points:

  • Using a project file is not mandatory and it should be possible to inspect/render single files.
  • If this is intended behavior, than quarto render should also fail and not run without any error.

Quarto creates the correct absolute path but adds subdir two times. When removing subdir from the include command in text2.qmd, the following error appears:

ERROR: Include directive failed.
  in file main.qmd, 
  in file ./subdir/text2.qmd, 
  could not find file /home/***/tmp/tarche-test/b/text3.qmd.

Stack trace:
  in file main.qmd, 
  in file ./subdir/text2.qmd, 
  could not find file /home/***/tmp/tarche-test/b/text3.qmd.
    at retrieveInclude (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:38818:19)
    at retrieveInclude (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:38840:23)
    at standaloneInclude (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:38854:11)
    at processMarkdownIncludes (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:39084:38)
    at expandIncludes (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:39113:11)
    at async projectResolveFullMarkdownForFile (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:39984:25)
    at async fileExecutionEngine (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:41500:26)
    at async inspectConfig (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:108671:24)
    at async Command.actionHandler (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:108740:20)
    at async Command.execute (file:///tmp/.mount_quarto1ukRte/usr/bin/quarto.js:8086:13)

@mcanouil
Copy link
Collaborator

Could you make a Git repository to share the structure of your project/example?
Could you also try what I suggested in my previous reply?

@mutlusun
Copy link
Author

Thanks for your feedback! The command also fails with a quarto project file.

Is it okay to share R code with you to create the file structure?

fs::dir_create("subdir")
fs::dir_create(file.path("subdir", "b"))
lines <- c(
  "---",
  "title: main",
  "format:",
  "  html:",
  "    default",
  "---",
  "",
  "{{< include \"./subdir/text1.qmd\" >}}"
)
writeLines(lines, "main.qmd")
lines <- c(
  "# First File",
  "",
  "Some text here.",
  "",
  "{{< include \"./subdir/b/text2.qmd\" >}}"
)
writeLines(lines, file.path("subdir", "text1.qmd"))
lines <- c(
  "# Second File",
  "",
  "Some text here.",
  ""
)
writeLines(lines, file.path("subdir", "b", "text2.qmd"))
lines <- c(
  "project:",
  "  output-dir: myoutdir",
  "  render:",
  "    - main.qmd"
)
writeLines(lines, "_quarto.yml")

quarto inspect . and quarto inspect main.qmd fails both. Render works.

@mcanouil
Copy link
Collaborator

mcanouil commented Nov 11, 2024

If you still use document relative paths, adding _quarto.yml won't change anything.

Quoting myself:

Add _quarto.yml and add leading / to tell Quarto the paths are relatives to the root.

@mutlusun
Copy link
Author

Add _quarto.yml and add leading / to tell Quarto the paths are relatives to the root.

You are right, now it works. But is it intended behavior that relative paths do not work? If it is intended behavior, I think quarto should error when relative paths are given.

@mcanouil mcanouil added the triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. label Nov 11, 2024
@cscheid cscheid added this to the v1.7 milestone Nov 14, 2024
@cscheid
Copy link
Collaborator

cscheid commented Nov 14, 2024

We definitely want to fix this but it might be too late to sneak this to the first 1.6 version. We'll do it in 1.7 and backport the fix.

@cderv cderv removed the triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport bug Something isn't working inspect
Projects
None yet
Development

No branches or pull requests

4 participants