quarto-ext / shinylive

Quarto extension to embed Shinylive for Python applications
https://quarto-ext.github.io/shinylive/
MIT License
144 stars 8 forks source link

`renv` library does not seem to be supported by extension lookup #35

Closed mcanouil closed 7 months ago

mcanouil commented 10 months ago

I tried https://github.com/coatless-quarto/r-shinylive-demo using a renv setup which is becoming the basis, but unfortunately, the shinylive extension is looking for the R shinylive package elsewhere.

See https://github.com/mcanouil/quarto-codespaces/tree/test/r-shinylive.

Am I missing something?

@mcanouil ➜ /workspaces/quarto-codespaces (test/r-shinylive) $ quarto preview /workspaces/quarto-codespaces/index.qmd --no-browser --no-watch-inputs
pandoc 
  to: html
  output-file: index.html
  standalone: true
  section-divs: true
  html-math-method: mathjax
  wrap: none
  default-image-extension: png

metadata
  document-css: false
  link-citations: true
  date-format: long
  lang: en
  title: Joe Cheng's r-shinylive App in a Quarto document!
  resources:
    - shinylive-sw.js

Warning message:
The 'yaml' package is required to parse dependencies within Quarto Markdown files
Consider installing it with `install.packages("yaml")`. 
Error in loadNamespace(x) : there is no package called ‘shinylive’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
(E) Error running 'Rscript' command. Perhaps you need to install / update the 'shinylive' R package?
 Error:
 pandoc.pipe.error {command: "Rscript", error_code: 1, output: ""}
Error running filter /opt/quarto/share/filters/main.lua:
...odespaces/_extensions/quarto-ext/shinylive/shinylive.lua:40: Error running 'Rscript' command. Perhaps you need to install / update the 'shinylive' R package?

stack traceback:
        ...odespaces/_extensions/quarto-ext/shinylive/shinylive.lua:40: in global 'throw_quarto_error'
        ...odespaces/_extensions/quarto-ext/shinylive/shinylive.lua:86: in global 'callRShinylive'
        ...odespaces/_extensions/quarto-ext/shinylive/shinylive.lua:113: in global 'callShinylive'
        ...odespaces/_extensions/quarto-ext/shinylive/shinylive.lua:286: in global 'ensureBaseSetup'
        ...odespaces/_extensions/quarto-ext/shinylive/shinylive.lua:315: in global 'ensureLanguageSetup'
        ...odespaces/_extensions/quarto-ext/shinylive/shinylive.lua:414: in function <...odespaces/_extensions/quarto-ext/shinylive/shinylive.lua:398>
        [C]: in ?
        [C]: in method 'walk'
        /opt/quarto/share/filters/main.lua:205: in local 'checked_walk'
        /opt/quarto/share/filters/main.lua:257: in function 'run_emulated_filter'
        /opt/quarto/share/filters/main.lua:917: in local 'callback'
        [string "..."]:1888: in field 'withScriptFile'
        /opt/quarto/share/filters/main.lua:930: in upvalue 'run_emulated_filter_chain'
        /opt/quarto/share/filters/main.lua:968: in function </opt/quarto/share/filters/main.lua:965>
stack traceback:
        /opt/quarto/share/filters/main.lua:205: in local 'checked_walk'
        /opt/quarto/share/filters/main.lua:257: in function 'run_emulated_filter'
        /opt/quarto/share/filters/main.lua:917: in local 'callback'
        [string "..."]:1888: in field 'withScriptFile'
        /opt/quarto/share/filters/main.lua:930: in upvalue 'run_emulated_filter_chain'
        /opt/quarto/share/filters/main.lua:968: in function </opt/quarto/share/filters/main.lua:965>

Edit: Rscript should be ran at the "working directory" used by Quarto.
annasoli commented 8 months ago

I am having the same problem. Any solution?

mcanouil commented 8 months ago

Using QUARTO_PROJECT_ROOT from quarto-dev/quarto-cli#8525 it should be possible for the extension to use renv if set in the project by running R from the root.

gcgbarbosa commented 7 months ago

If you are on windows, I fixed this error by adding R/bin folder to PATH.

mcanouil commented 7 months ago

@gcgbarbosa How does this solved the issue about renv exactly?

gcgbarbosa commented 7 months ago

I was getting the same error as you. My Rscript binary was not in PATH.

Note that the stracktrace is complaining about:

_extensions/quarto-ext/shinylive/shinylive.lua:40: Error running 'Rscript' command. Perhaps you need to install / update the 'shinylive' R package?
mcanouil commented 7 months ago

That's not the issue.

You can see that using the Codespace setup of my reproducible example, in which Rscript is in the path, but the shinylive R package is only available via renv library. image

Edit: it seems, the error no longer appears. Quarto version used in the Docker image was upgraded and several changes regarding R code path were done in Quarto CLI. I am checking now with the latest pre-release before closing this.

mcanouil commented 7 months ago

Recent version of Quarto CLI and shinylive extension no longer exhibit the issue. Tested with 1.4.549 and 1.5.13. Latest version of the shinylive and renv R packages, on the latest R version.

image