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

Web URL not rendered in book page-footers on Windows #8737

Closed
Hemken opened this issue Feb 14, 2024 · 4 comments · Fixed by #8845
Closed

Web URL not rendered in book page-footers on Windows #8737

Hemken opened this issue Feb 14, 2024 · 4 comments · Fixed by #8845
Assignees
Labels
bug Something isn't working windows
Milestone

Comments

@Hemken
Copy link

Hemken commented Feb 14, 2024

Bug description

When rendering a book project on a Windows platform, when a page-footer includes a URL to a web site, Quarto errors out. No output document is produced.

The same files, when rendered on a Linux platform, work as expected.

Steps to reproduce

  • quarto create project book test-book
  • add to _quarto.yml (under chapters:)
    page-footer:
      left:
        - text: "Quarto"
          href: "https://quarto.org"
    
  • render project on a Windows computer

Expected behavior

This should render an HTML book, with the appropriate link in the page footer.

Actual behavior

When rendered in Rstudio, the following result appears in the Background Jobs tab

ERROR: The specified path is invalid. (os error 161): stat 'Z:\test-book\https:\quarto.org'

Stack trace:
    at Object.statSync (ext:deno_fs/30_fs.js:363:7)
    at createWalkEntrySync (file:///C:/PROGRA~1/Quarto/bin/quarto.js:2305:23)
    at expandGlobSync (file:///C:/PROGRA~1/Quarto/bin/quarto.js:2439:25)
    at expandGlobSync.next (<anonymous>)
    at expandGlobs (file:///C:/PROGRA~1/Quarto/bin/quarto.js:5448:24)
    at resolveGlobs (file:///C:/PROGRA~1/Quarto/bin/quarto.js:5525:26)
    at resolvePathGlobs (file:///C:/PROGRA~1/Quarto/bin/quarto.js:5460:12)
    at projectInputFiles (file:///C:/PROGRA~1/Quarto/bin/quarto.js:73059:26)
    at projectContext (file:///C:/PROGRA~1/Quarto/bin/quarto.js:72803:44)
    at eventLoopTick (ext:core/01_core.js:183:11)
Error in `processx::run(quarto_bin, args, echo = TRUE)`:
! System command 'quarto.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Backtrace:
1. .rs.sourceWithProgress(script = "C:/Users/hemken/AppData/Local/Temp/RtmpkH…
2. base::eval(statements[[idx]], envir = globalenv())
3. base::eval(statements[[idx]], envir = globalenv())
4. quarto::quarto_render()
5. processx::run(quarto_bin, args, echo = TRUE)
6. processx:::throw(new_process_error(res, call = sys.call(), echo = echo, …
Execution halted

Your environment

  • IDE: RStudio 2023.09.1+494 "Desert Sunflower" Release (cd7011dce393115d3a7c3db799dda4b1c7e88711, 2023-10-16) for windows
  • OS: Windows 10

Quarto check output

Quarto 1.4.549
[>] 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.549
Path: C:\Program Files\Quarto\bin
CodePage: 1252

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

[>] Checking LaTeX....................OK
Using: Installation From Path
Path: C:\Program Files\texlive\2023\bin\windows
Version: 2023

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

[>] Checking Python 3 installation....(None)

  Unable to locate an installed version of Python 3.
  Install Python 3 from https://www.python.org/downloads/

(|) Checking R installation...........Finished Rprofile.site
[>] Checking R installation...........OK
Version: 4.3.2
Path: C:/PROGRA1/R/R-431.2
LibPaths:
- U:/R/4.3.2
- C:/Program Files/R/R-4.3.2/site-library
- C:/Program Files/R/R-4.3.2/library
knitr: 1.45
rmarkdown: 2.25

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

@Hemken Hemken added the bug Something isn't working label Feb 14, 2024
@Hemken
Copy link
Author

Hemken commented Feb 14, 2024

I should add that this seems to be specifically a problem with book projects, not single page website projects.

@cscheid cscheid added the triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. label Feb 14, 2024
@mcanouil
Copy link
Collaborator

FWIW, on macOS, it works as expected.

@cderv cderv removed the triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. label Feb 22, 2024
@cderv
Copy link
Collaborator

cderv commented Feb 22, 2024

This is unexpected that the error happens from projectInputFiles. We go through here:

const renderFiles = metadata?.project[kProjectRender];
if (renderFiles) {
const exclude = projIgnoreGlobs.concat(outputDir ? [outputDir] : []);
const resolved = resolvePathGlobs(dir, renderFiles, exclude, {
mode: "auto",
});

and it errors because renderFiles = metadata?.project[kProjectRender]; contains the website

> metadata.project.render
[
  "index.qmd",
  "intro.qmd",
  "summary.qmd",
  "references.qmd",
  "https://quarto.org",
]

I need to look how it goes on linux. It reminds me of issue with path detection between Linux and Windows for https:://

This could end up there because page-footer may possibly take a .qmd file so we add in Render when detected, and we detect wrong on Windows.

@cderv
Copy link
Collaborator

cderv commented Feb 22, 2024

Any href in page-footer will be considered a file to render

// Add any files that are in the footer to the render list
const footerFiles: string[] = [];
const pageFooter = resolvePageFooter(config);
const addFooterItems = (region?: PageFooterRegion) => {
if (region) {
for (const item of region) {
if (typeof item !== "string") {
const navItem = item as NavigationItemObject;
if (navItem.href) {
footerFiles.push(navItem.href);
}
}
}
}
};
addFooterItems(pageFooter.left);
addFooterItems(pageFooter.right);
addFooterItems(pageFooter.center);
config.project[kProjectRender].push(...footerFiles);

That is why it ended up in render list file.

This list will go through resolvePathGlobs to be expanded to absolute path and this is where the issue happens on Windows.

I believe this windows issue is just unveiling a hidden behavior in Linux: URL that gets in glob to be expanded in our function

quarto-cli/src/core/path.ts

Lines 177 to 190 in d047195

const expandGlobs = (targetGlobs: string[]) => {
const expanded: string[] = [];
for (const glob of targetGlobs) {
for (
const file of expandGlobSync(
glob,
{ root, exclude, includeDirs: true, extended: true, globstar: true },
)
) {
expanded.push(file.path);
}
}
return ld.uniq(expanded);
};

with expandGlobSync are just filtered out.

Behavior on Linux

> import { expandGlobSync } from "https://deno.land/std@0.217.0/fs/mod.ts";
undefined
> const href = "https://quarto.org"
undefined
> for (file of expandGlobSync(href)) { console.log(file) }
undefined

Behavior on Windows

> import { expandGlobSync } from "https://deno.land/std@0.217.0/fs/mod.ts";
undefined
> const href = "https://quarto.org"
undefined
>  for (file of expandGlobSync(href)) { console.log(file) }
Uncaught Error: La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte. (os error 123): stat 'C:\Users\chris\AppData\Local\Temp\quarto\https:\quarto.org'
    at Object.statSync (ext:deno_fs/30_fs.js:425:3)
    at createWalkEntrySync (https://deno.land/std@0.217.0/fs/_create_walk_entry.ts:22:21)
    at expandGlobSync (https://deno.land/std@0.217.0/fs/expand_glob.ts:264:21)
    at expandGlobSync.next (<anonymous>)
    at <anonymous>:1:27

Deno ignores this because it handle error for file not found at https://deno.land/std@0.217.0/fs/expand_glob.ts?source=#L136

  let fixedRootInfo: WalkEntry;
  try {
    fixedRootInfo = await createWalkEntry(fixedRoot);
  } catch (error) {
    return throwUnlessNotFound(error);
  }

So this could also be seen as a Deno bug. It is really to same issue of invalid path on windows, not being seen as invalid on Linux. Windows errors for invalid path before not found error.

Previously we add this type of error with existsSync() so we added safeExistsSync().

Related issue is #4124 with fix at #4129 by checking for https path.

So should probably be the same fix here for book with page footer file detection.

However, I think we are impacted by this hidden behavior in several places we'll keep discovering

@cderv cderv added this to the v1.5 milestone Feb 22, 2024
cderv added a commit that referenced this issue Feb 22, 2024
Change has been made in 90e04f4 following discussion in #3441 to allow `href` being a .qmd file to be rendered.

Though when `href` is a link, it made Windows fails because our globExpanson on Linux knows to ignore https:// one, and on Windows it doesn't. Deno behavior for `expandGlobSync` - see discussion in issue #8737)
cderv added a commit that referenced this issue Feb 22, 2024
Change has been made in 90e04f4 following discussion in #3441 to allow `href` being a .qmd file to be rendered.

Though when `href` is a link, it made Windows fails because our globExpanson on Linux knows to ignore https:// one, and on Windows it doesn't. Deno behavior for `expandGlobSync` - see discussion in issue #8737)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants