quarto-dev / quarto-cli

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

Quarto document will not render #8258

Closed jrtheobald closed 8 months ago

jrtheobald commented 9 months ago

Bug description

While running the demonstration provided by the Quarto website with a qmd document about palmer penguins in R studio on Windows I receive an error.

==> quarto preview hello.qmd --to html --no-watch-inputs --no-browse

Error in inDL(x, as.logical(local), as.logical(now), ...) : 
  unable to load shared object 'C:/Users/jrthe/AppData/Local/R/win-library/4.3/rlang/libs/x64/rlang.dll':
  LoadLibrary failure:  The specified procedure could not be found.
Calls: :: ... namespaceImport -> loadNamespace -> library.dynam -> dyn.load -> inDL
Execution halted
R scripting front-end version 3.6.1 (2019-07-05)

Unable to locate an installed version of R.
Install R from https://cloud.r-project.org/

No report renders. The following is the session info for R studion:

> sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.3.2  cli_3.6.1       tools_4.3.2     rstudioapi_0.14 knitr_1.42      xfun_0.39      

And the stack trace on windows in powershell as requested in the bug report guide:

PS C:\Users\jrthe> $ENV:QUARTO_PRINT_STACK="true"
PS C:\Users\jrthe> quarto render document.qmd
ERROR: No valid input files passed to render

Stack trace:
    at Command.fn (file:///C:/Users/jrthe/AppData/Local/Programs/Quarto/bin/quarto.js:81959:15)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async Command.execute (file:///C:/Users/jrthe/AppData/Local/Programs/Quarto/bin/quarto.js:8102:13)

R studio version:

> RStudio.Version()
$citation
To cite RStudio in publications use:

  Posit team (2023). RStudio: Integrated Development Environment for R. Posit Software, PBC, Boston, MA. URL
  http://www.posit.co/.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {RStudio: Integrated Development Environment for R},
    author = {{Posit team}},
    organization = {Posit Software, PBC},
    address = {Boston, MA},
    year = {2023},
    url = {http://www.posit.co/},
  }

$mode
[1] "desktop"

$version
[1] β€˜2023.12.0.369’

$long_version
[1] "2023.12.0+369"

$release_name
[1] "Ocean Storm"

Steps to reproduce

  1. Install latest version of R Windows.
  2. Install latest version of RStudio Windows.
  3. Install lastest version of Quarto for Windows.
  4. Installed and loaded packages.
  5. Downloaded the palmer penguins qmd.
  6. Clicked Render.
    
    ---
    title: "Hello, Quarto"
    format: html
    editor: visual
    ---

{r}

| label: load-packages

| include: false

library(tidyverse) library(palmerpenguins)

Meet Quarto

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

Meet the penguins

The penguins data from the palmerpenguins package contains size measurements for r nrow(penguins) penguins from three species observed on three islands in the Palmer Archipelago, Antarctica.

The plot below shows the relationship between flipper and bill lengths of these penguins.

{r}

| label: plot-penguins

| warning: false

| echo: false

ggplot(penguins, aes(x = flipper_length_mm, y = bill_length_mm)) + geom_point(aes(color = species, shape = species)) + scale_color_manual(values = c("darkorange","purple","cyan4")) + labs( title = "Flipper and bill length", subtitle = "Dimensions for penguins at Palmer Station LTER", x = "Flipper length (mm)", y = "Bill length (mm)", color = "Penguin species", shape = "Penguin species" ) + theme_minimal()


### Expected behavior

I was expecting a rendered report to show up as indicated by the demonstration video under getting started with Quarto.  No report rendered.

### Actual behavior

Background tabs open in R Studio and process begins, but returns error.

### Your environment

R Version 4.3.2
Platform x86_64-w64-mingw32/x64 (64_bit)
Running Under; Windows 11 x64 (build 22621)
R studio version:  Ocean Storm 2023.12.0+369, desktop

### Quarto check output

C:\Users\jrthe\Documents\quarto_practice>quarto check Quarto 1.4.542 [>] 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.542 Path: C:\Users\jrthe\AppData\Local\Programs\Quarto\bin CodePage: unknown

[>] 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.11.5 (Conda) Path: C:/Users/jrthe/anaconda3/python.exe Jupyter: 5.3.0 Kernels: ir, python3

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

(|) Checking R installation...........R scripting front-end version 3.6.1 (2019-07-05) [>] Checking R installation...........(None)

  Unable to locate an installed version of R.
  Install R from https://cloud.r-project.org/
mcanouil commented 9 months ago

what if you open an R terminal and type library(rlang)? The first error message indicates a corrupted R package installation independent of Quarto.

Could you format your code properly using four backticks to enclose your document?

Does R is available in your PATH? Did you register R in the Windows registry when you installed it? Because quarto check should have found R, but did not so something is not standard in your setup.

cscheid commented 9 months ago

quarto render document.qmd

You probably need to run quarto render hello.qmd instead, since that's the name of your document.

jrtheobald commented 9 months ago

There's some kind of issue with the qmd file provided in the Quarto tutorial. New qmd files seem to render just fine.

cscheid commented 9 months ago

There's some kind of issue with the qmd file provided in the Quarto tutorial. New qmd files seem to render just fine.

Which file are you referring to?

cderv commented 9 months ago

Based on your log, I think you have an issue with your environment configuration.

(|) Checking R installation...........R scripting front-end version 3.6.1 (2019-07-05)

This means that Rscript --version is using R 3.6.1 and not R 4.3.2 as you are mentioning.

Quarto is calling RScript, and quarto check is calling Rscript --version to have the version number.

So definitely something happening in which version Quarto is using.

unable to load shared object 'C:/Users/jrthe/AppData/Local/R/win-library/4.3/rlang/libs/x64/rlang.dll':

As mentioned above this means that the rlang package used as an issue loading. It should be the same issue in your R console.

So something is not right in your environment.

There's some kind of issue with the qmd file provided in the Quarto tutorial

The file at https://quarto.org/docs/get-started/hello/rstudio.html will use a bunch of packages, including tidyverse , which includes rlang.

Thank you

adugyamfinicholas commented 9 months ago

I had a similar issue, and following cderv's suggestion, I found that I had installed anaconda that had installed R version 3.6.1. I am able to render after uninstalling anaconda.

cderv commented 9 months ago

I found that I had installed anaconda that had installed R version 3.6.1. I am able to render after uninstalling anaconda.

@adugyamfinicholas Thanks for this information. Was anaconda environment activated when you ran Quarto ? I am guessing this could explain how the R anaconda got into the PATH.

I'll try to think about ways to maybe detect anaconda R and warn or message about this πŸ€”

mcanouil commented 9 months ago

@cderv Maybe worth adding the path of the R detected by quarto check as done for Python and Quarto. With the path of the R executable, it would have been easy to see the anaconda issue.

cderv commented 9 months ago

@mcanouil Sorry I do not follow - in a working quarto check the Path is shown

[>] Checking R installation...........OK
      Version: 4.3.2
      Path: C:/PROGRA~1/R/R-43~1.2
      LibPaths:
        - C:/Users/chris/AppData/Local/R/win-library/4.3
        - C:/Program Files/R/R-4.3.2/library
      knitr: 1.45.9
      rmarkdown: 2.25

See Path field in the output

With the path of the R executable, it would have been easy to see the anaconda issue.

Issue here is that an error happens during quarto check knitr which lead to undetected R installation, so nothing reported. We improved the reporting in Quarto 1.4 (especially in debug verbose mode, and probably there the path is shown even when error), and we have an improvement issue for quarto check output opened already.

So we'll do the necessary improvement, but the path of the R detected by quarto check is already in the logged output

mcanouil commented 9 months ago

Yes I know it is supposed to "work".

I was referring to the truncated quarto check output which somehow did not show any of the usual information because of the failure you talked about. What I was saying/suggesting was to show Path independently of the results of the status checks. Status checks should not error out but print errors only and keep doing its job.

(|) Checking R installation...........R scripting front-end version 3.6.1 (2019-07-05)
[>] Checking R installation...........(None)

    Unable to locate an installed version of R.
    Install R from https://cloud.r-project.org/
cderv commented 9 months ago

Thanks for the clarification. That makes more sense.

We already did this in https://github.com/quarto-dev/quarto-cli/pull/7013 by adding more information about R found in debug mode. (https://quarto.org/docs/troubleshooting/#verbose-mode). We could revisit it, but it is best discussed in another issue. Thanks.

adugyamfinicholas commented 9 months ago

I found that I had installed anaconda that had installed R version 3.6.1. I am able to render after uninstalling anaconda.

@adugyamfinicholas Thanks for this information. Was anaconda environment activated when you ran Quarto ? I am guessing this could explain how the R anaconda got into the PATH.

I'll try to think about ways to maybe detect anaconda R and warn or message about this πŸ€”

Yes anaconda environment was activated when I run render in rstudio. Anothing interesting find was that it only occured when i am in an R project environment, when i am not it worked fine.

jrtheobald commented 8 months ago

Initially, I believed there was an issue with one of the qmd files provided in one of the tutorials (Palmer penguins). I thought that because new files would render, but the tutorial's file would not. I again attempted to render a new file today, but I saved it a few days ago and returned to it today. The file I created would not render. I uninstalled Anaconda, and now the file renders. I suppose the problem arises from having both Rstudio/R and Anaconda/R (although I only wanted to use Anaconda for Python).

jrtheobald commented 8 months ago
  • Can you check if you have different R installations?

I initially had multiple versions of R. In troubleshooting I uninstalled all versions of R, Rstudio, and Anaconda. Then I reinstalled the latest versions of R and Rstudio, and Anaconda.

  • Can you check which RScript is in PATH?

    • open PowerShell and do gcm Rscript or CMD and where Rscript

Running gcm Rscript did not returned an error that Rscript is unrecognizable, object not found.

  • Can you provide us with more debug information by

The current version of Quarto installed is 1.4.542.

There's some kind of issue with the qmd file provided in the Quarto tutorial

The file at https://quarto.org/docs/get-started/hello/rstudio.html will use a bunch of packages, including tidyverse , which includes rlang.

I think I had all the required packages installed and loaded when I tried to render. But when I create a new Quarto document preloaded with code absent any packages even that would not render.

jistria commented 8 months ago

I have also encountered this issue when attempting to render a Quarto document in R (not RStudio - it works fine in RStudio). My environment is:

@cderv's advice to set the env var QUARTO_LOG_LEVEL="DEBUG" was very helpful in diagnosing my issues.

It works when I set the env var QUARTO_R = "C:/Program Files/R/R-4.3.2/bin" or QUARTO_R = "C:/Program Files/R/R-4.3.2/bin/x64". It does not work when I set the env var to QUARTO_R = "C:/Program Files/R/R-4.3.2", which I mention as it wasn't immediately obvious to me from reading https://quarto.org/docs/computations/r.html#installation.

It also works after I set the env var R_HOME = "C:/Program Files/R/R-4.3.2/bin" or R_HOME = "C:/Program Files/R/R-4.3.2/bin/x64". It does not work with the following:

Is it intended that it would work with the default R_HOME value? This seems ideal to me.

Finally, I found that quarto was unable to find R via the registry because of a Group Policy set by my IT dept. reg query HKLM\Software\R-core\R\4.3.2 Patched /v InstallPath returns ERROR: Registry editing has been disabled by your administrator.. When I execute quarto check in PowerShell opened as admin, it is able to find R via the registry. Is there an alternative method of checking the registry that will not get blocked by a Group Policy? FWIW, R's base::readRegistry works for me without admin rights.

Without applying these solutions, Quarto attempts to find Rscript in program files, happens to find the oldest version of R I have installed on my machine, and then encounters some error. See below for relevant verbose results from calling quarto check via R (i.e. shell("quarto check")).

-- Searching for R binary --
Looking for 'Rscript' in QUARTO_R: undefined
Looking for 'Rscript' in R_HOME: C:/PROGRA~1/R/R-43~1.2
Looking for 'Rscript' in PATH.
[execProcess] CMD /C where Rscript
(|) Checking R installation...........[execProcess] Success: false, code: 1
Looking for 'Rscript' in Windows Registry.
[execProcess] reg query HKCU\Software\R-core\R /v Current Version
[execProcess] Success: false, code: 1
[execProcess] reg query HKLM\Software\R-core\R /v Current Version
[execProcess] Success: false, code: 1
Looking for 'Rscript' in Windows PROGRAMFILES.
Found C:\Program Files\R\R-4.0.2\bin
[execProcess] C:\Program Files\R\R-4.0.2\bin\Rscript --version
(/) Checking R installation...........R scripting front-end version 4.0.2 (2020-06-22)
(-) Checking R installation...........[execProcess] Success: true, code: 0

++R found at C:\Program Files\R\R-4.0.2\bin\Rscript is not working properly.
[>] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/

Thanks in advance for your time!

cderv commented 8 months ago

It does not work when I set the env var to QUARTO_R = "C:/Program Files/R/R-4.3.2", which I mention as it wasn't immediately obvious to me from reading quarto.org/docs/computations/r.html#installation.

We could improve documentation at https://quarto.org/docs/computations/r.html#installation maybe. It is implied from the sentence

You can override the version of R used by Quarto by setting the QUARTO_R environment variable.

that a path where R binaries can be found should be provided.

Is it intended that it would work with the default R_HOME value? This seems ideal to me.

As this is the default value, and we wanted to use it, we do append bin/ directly to it as we know the binaries should be in it https://github.com/quarto-dev/quarto-cli/blob/1263080154060a3292f2c677468a2421aa3b8de6/src/core/resources.ts#L101-L118

We don't do that assumption with QUARTO_R because as this is user-defined, we expect a path that directly contains the R binaries. https://github.com/quarto-dev/quarto-cli/blob/1263080154060a3292f2c677468a2421aa3b8de6/src/core/resources.ts#L85-L99

Finally, I found that quarto was unable to find R via the registry because of a Group Policy set by my IT dept. reg query HKLM\Software\R-core\R\4.3.2 Patched /v InstallPath returns ERROR: Registry editing has been disabled by your administrator.. When I execute quarto check in PowerShell opened as admin, it is able to find R via the registry. Is there an alternative method of checking the registry that will not get blocked by a Group Policy? FWIW, R's base::readRegistry works for me without admin rights.

This is interesting feedback. I'll try to see if I can reproduce, and see if there is a solution we could leverage, that don't required admin right. I wasn't aware of this admin requirement to be honest... πŸ€”

Without applying these solutions, Quarto attempts to find Rscript in program files, happens to find the oldest version of R I have installed on my machine, and then encounters some error. See below for relevant verbose results from calling quarto check via R

This is surprising why R 4.0.2 would not work. I'll try to reproduce also. πŸ€”

github-actions[bot] commented 8 months 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.