Problems with rlang in RStudio on RAP?

I'm having persistent issues with rlang in RStudio on RAP. I *think* the issue is that some of the packages I try to install depend on versions higher than the version 1.0.1 installed automatically. But apparently, because other packages (e.g. htmltools) depend on it, it can't be unloaded and replaced with the updated version.   I've tried restarting R, but I think some packages don't get unloaded (maybe because RMarkdown depends on them?). Sometimes, I seem to be able to fix it by chasing down different chains of dependencies. But it doesn't always work and is slow. Has anyone else come across this issue, and found a reliable solution?   Sorry for the slightly vague question and lack of code (I terminated my instance too quickly!)

Comments

2 comments

  • Comment author
    Alexandra Lee DNAnexus Team

    Maybe try installing your packages in an RStudio notebook using the Jupyter Lab Tool instead. The version of R used in jupyter lab is 4.2.0 (rlang version 1.0.6) instead of R in RStudio is 4.1.1 (rlang version 1.0.1)

    0
  • Comment author
    Vu Hoang Nguyen

    I assume you are running your code in a R markdown or notebook in RStudio.

     

    For those document types, RStudio automatically load various packages to support visualization, hence rlang is pre-loaded. If we try to unload it, a conflict would arise since other packages depend on rlang.

     

    unloadNamespace("rlang")

    -->

    Error in unloadNamespace("rlang") :

    namespace ?rlang? is imported by ?pillar?, ?vctrs?, ?ggplot2?, ?purrr?, ?lifecycle?, ?tibble?, ?ellipsis?, ?dplyr?, ?tidyselect? so cannot be unloaded

     

     

     

    To overcome the above error, we could sequentially `unload` each package listed above until there is no dependant packages left.

     

    For example, in a R markdown document, I put this setup chunk at the start of the document:

     

    ```{r setup, include=FALSE}

    unloadNamespace('jquerylib') # Because jqeurylib, rmarkdown, htmltools depends on rlang so they need to be unloaded first

    unloadNamespace('rmarkdown')

    unloadNamespace('htmltools')

    unloadNamespace('rlang')

    install.packages('rlang') # Install the latest version

    library(rlang) # Load latest version rlang

    sessionInfo()

    ```

     

    The output from sessionInfo() shows us if and which version of rlang is currently loaded.

     

     

    This issue only arise for R markdown and Notebook. I tried running a simple Rscript (.R) and rlang is not automatically loaded.

    0

Please sign in to leave a comment.