quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.99k stars 328 forks source link

`quarto preview` in a Hugo project seems to require a Hugo installation in a different directory than `blogdown::install_hugo()` provides #6435

Open kleinlennart opened 1 year ago

kleinlennart commented 1 year ago

Bug description

ERROR: NotFound: No such file or directory (os error 2)

NotFound: No such file or directory (os error 2)
    at opRun (deno:runtime/js/40_process.js:33:16)
    at Object.run (deno:runtime/js/40_process.js:116:17)
    at externalPreviewServer (file:///Applications/quarto/bin/quarto.js:103269:27)
    at serveProject (file:///Applications/quarto/bin/quarto.js:103212:240)
    at async Command.fn (file:///Applications/quarto/bin/quarto.js:103749:13)
    at async Command.execute (file:///Applications/quarto/bin/quarto.js:8437:13)
    at async quarto (file:///Applications/quarto/bin/quarto.js:127542:5)
    at async file:///Applications/quarto/bin/quarto.js:127560:9
==> Found hugo at "/Users/lennart/Library/Application Support/Hugo/0.116.1/hugo" and "/usr/local/bin/hugo". The former will be used. If you don't need both copies, you may delete/uninstall the latter with system("brew uninstall hugo") in R.

Steps to reproduce

The _quarto.yml used for the project:

project:
  type: hugo
  render:
    - "*.qmd"
    - "!archetypes/"

format:
  hugo-md

With the Quarto files in content/post/**/index.qmd. -> It works perfectly fine after brew installing Hugo.

Your environment

Quarto check output

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.3.433
      Path: /Applications/quarto/bin

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

[✓] Checking Python 3 installation....OK
      Version: 3.8.17 (Conda)
      Path: /Users/lennart/anaconda3/envs/r-reticulate/bin/python
      Jupyter: 5.3.0
      Kernels: python3

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

[✓] Checking R installation...........OK
      Version: 4.3.1
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Users/lennart/Library/R/x86_64/4.3/library
        - /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
      knitr: 1.43
      rmarkdown: 2.23

[✓] Checking Knitr engine render......OK
mcanouil commented 1 year ago

Thanks for the report!

Could you share a small self-contained "working" (reproducible) example to work with, i.e., a complete Quarto document or a Git repository? Thanks.

github-actions[bot] commented 1 year ago

Thank you for using Quarto and reporting an issue!

Unfortunately, this issue is now considered stale because it has been opened since 14 days without providing a "working" reproducible example to help us investigate. If you are still facing the issue, please review the "Bug Reports" guide on how to provide a fully reproducible example as a self-contained Quarto document or a link to a Git repository. Without a reproducible example, it is unlikely that the issue will be addressed.

You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````).

````qmd
---
title: "Reproducible Quarto Document"
format: html
---

This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.

```{r}
plot(cars)

The end.

cderv commented 1 year ago

TL;DR

Details

We may not add all the details in our doc, but using quarto preview for such project will serve using hugo serve

This implies the hugo command is in the PATH. Quarto does not search for the command (as it would do for R or Python). blogdown does install Hugo with an installer but it does not add to PATH by default. This is because blogdown is designed to help maintain several project with different Hugo versions, and configure the version to use in project's .Rprofile.

With Quarto, you would need to add the hugo command path you want to use in the PATH variable for the project. Using environment variables feature from Quarto could help do that at project level and not system wise.

I am not sure how we can improve this or what is the best idea. Quarto is not meant to manage Hugo and quarto preview is just a convenient way to run hugo serve --port {port} --bind {host} --navigateToChanged for the user.

A workflow could also be to run this command on the output folder, and works in quarto source project to render files and live preview.

We'll keep this open to see if we can find a way to improve for blogdown users.

RKonstantinR commented 1 year ago

I ran into the same problem, but under different circumstances.

User case: I have a Hugo site on Cloudflare.

The site is automatically rebuilt when updates are pushed to github.

After reading an article about Quarto (https://quarto.org/docs/output-formats/hugo.html) I decided to try to integrate the content generated using Quarto into my site, and also ensure that the site is updated when updates are pushed to git.

This requires the ability to preview content in hugo format.

To generate content, I use RStudio Server, which is deployed using Docker.

I created an R project in Rstudio using Git (clone my Hugo site git-project).

And in this project, no quarto documents are generated at all. I get the same error as the author.

Does this approach work? Is there a way to use quarto preview in Rstudio Server?

cderv commented 1 year ago

@RKonstantinR do you have hugo install and findable in PATH ?

RKonstantinR commented 1 year ago

@RKonstantinR do you have hugo install and findable in PATH ?

I added hugo installation to my dockerfile: RUN apt-get install hugo

And when I render a quarto-document, it generates plain markdown files (.md), but a blank page opens in the browser.

Is it possible to preview hugo pages using Rstudio-server?

cderv commented 1 year ago

I added hugo installation to my dockerfile: RUN apt-get install hugo

Can you check the hugo version ? hugo version

It is possible that the version available in official repo is quite old. Follow step at https://gohugo.io/installation/linux/ to install hugo.

You need a recent version of Hugo if you follow the quickstart (https://quarto.org/docs/output-formats/hugo.html#creating-a-page) as Page Bundles is from v0.32.

Current version is 0.118.2 so I would advice to use a recent one.

https://github.com/gohugoio/hugo/releases/tag/v0.32

To be clear, it works. hugo serve is called by Quarto FWIW.

RKonstantinR commented 1 year ago

Thanks for your reply!

You were right, the old version of Hugo (v0.92.2) was installed from the official repository.

I edited the dockerfile and installed the latest version of Hugo (v0.118.2):

# download deb file
RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.118.2/hugo_0.118.2_linux-amd64.deb -o hugo.deb

# install
RUN apt-get install ./hugo.deb

When I render a quarto-document, it generates plain markdown files (.md), but the browser shows the page "Page Not Found"

My enviropment:

R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

My qmd:

---
title: "Test"
date: "2023-09-19"
format: hugo-md
---

## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.

## Running Code

When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

```{r}
1 + 1

The echo: false option disables the printing of code (only output is displayed).


Quarto check output:

[✓] Checking versions of quarto binary dependencies... Pandoc version 3.1.1: OK Dart Sass version 1.55.0: OK [✓] Checking versions of quarto dependencies......OK [✓] Checking Quarto installation......OK Version: 1.3.450 Path: /opt/quarto/bin

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

[✓] Checking Python 3 installation....OK Version: 3.10.12 Path: /tmp/Rtmp8opg1O/rstudio/terminal/python3 Jupyter: (None)

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

[✓] Checking R installation...........OK Version: 4.3.1 Path: /usr/local/lib/R LibPaths:

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


Quarto preview (in terminal):

Terminating existing preview server....DONE

Preparing to preview

Watching files for changes Watching for changes in /home//{archetypes,assets,content,layouts,static} Watching for config changes in /home//config/_default Start building sites … hugo v0.118.2-da7983ac4b94d97d776d7c2405040de97e95c03d linux/amd64 BuildDate=2023-08-31T11:23:51Z VendorInfo=gohugoio

WARN found no layout file for "html" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination. WARN found no layout file for "html" for kind "section": You should create a template file which matches Hugo Layouts Lookup Rules for this combination. WARN found no layout file for "html" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination. WARN found no layout file for "html" for layout "simple" for kind "section": You should create a template file which matches Hugo Layouts Lookup Rules for this combination. WARN found no layout file for "html" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination. WARN found no layout file for "html" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination. WARN found no layout file for "json" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

               | EN  

-------------------+----- Pages | 10
Paginator pages | 0
Non-page files | 14
Static files | 7
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0

Built in 25 ms Environment: "development" Serving pages from memory Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender http://localhost:4759/ Web Server is available at http://localhost:4759/ (bind address 127.0.0.1)

cderv commented 1 year ago

I think to move forward you need to create a Github repo of what you are trying to do, and share it here. This will be easier than me asking question (like what is your project organization).

This way I can clone the repo and try on my side. I did a quick test following hugo quickstart and adding a .qmd and it all worked fine

Also next time, please do open a new issue. This issue is about blogdown install version of Hugo, and not your rendering issue. So open a new issue, and share a github repo with your problem. Thank you