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

Installing knitr 1.37 from CRAN in R 4.1.2 failed #2087

Closed
jlduan opened this issue Dec 18, 2021 · 11 comments
Closed

Installing knitr 1.37 from CRAN in R 4.1.2 failed #2087

jlduan opened this issue Dec 18, 2021 · 11 comments

Comments

@jlduan
Copy link

jlduan commented Dec 18, 2021

Hi,

Thanks for this wonderful package. I have some difficulties installing the latest 1.37 version. Tried remotes::install_github('yihui/knitr'), the same error.

Best

> install.packages('knitr')
Installing package into ‘/opt/homebrew/lib/R/4.1/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/knitr_1.37.tar.gz'
Content type 'application/x-gzip' length 895567 bytes (874 KB)
==================================================
downloaded 874 KB

* installing *source* package ‘knitr’ ...
** package ‘knitr’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
Error : .onLoad failed in loadNamespace() for 'glue', details:
  call: NULL
  error: 'knit_engines' is not an exported object from 'namespace:knitr'
Error: unable to load R code in package ‘knitr’
Execution halted
ERROR: lazy loading failed for package ‘knitr’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/knitr’
* restoring previous ‘/opt/homebrew/lib/R/4.1/site-library/knitr’

The downloaded source packages are in
        ‘/private/var/folders/yr/vrcclyl91kd_dg97yrqtwqz40000gn/T/RtmpcwyqsX/downloaded_packages’
Warning message:
In install.packages("knitr") :
  installation of package ‘knitr’ had non-zero exit status
>
R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20.6.0 (64-bit)
Running under: macOS Monterey 12.1

Matrix products: default
BLAS:   /opt/homebrew/Cellar/openblas/0.3.18/lib/libopenblasp-r0.3.18.dylib
LAPACK: /opt/homebrew/Cellar/r/4.1.2/lib/R/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2
>

By filing an issue to this repo, I promise that

  • [ x] I have fully read the issue guide at https://yihui.org/issue/.
  • [ x] I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • [x ] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui
Copy link
Owner

yihui commented Dec 19, 2021

I have no idea why that happens, but I strongly recommend that you install R via brew install --cask r instead of brew install r. Currently you seem to have installed R in the latter way.

@jlduan
Copy link
Author

jlduan commented Dec 19, 2021

Thanks for the reply and suggestion!
I'm probably going to migrate to cask at next R version release.

@yihui yihui closed this as completed Dec 20, 2021
@cderv
Copy link
Collaborator

cderv commented Dec 20, 2021

Error : .onLoad failed in loadNamespace() for 'glue', details:
 call: NULL
 error: 'knit_engines' is not an exported object from 'namespace:knitr'

This could also be related to glue. There was an update the same day of the last knitr release. You could try

  1. uninstalling glue
  2. installing knitr
  3. reinstalling glue

It may work if this is indeed the issue.

@jlduan
Copy link
Author

jlduan commented Dec 21, 2021

Error : .onLoad failed in loadNamespace() for 'glue', details:
 call: NULL
 error: 'knit_engines' is not an exported object from 'namespace:knitr'

This could also be related to glue. There was an update the same day of the last knitr release. You could try

  1. uninstalling glue
  2. installing knitr
  3. reinstalling glue

It may work if this is indeed the issue.

Hi,

Thanks for the suggestion. I have tried uninstalling glue. It's the same error.

Uninstall glue & install knitr

> remove.packages('glue')
Removing package from ‘/opt/homebrew/lib/R/4.1/site-library’
(as ‘lib’ is unspecified)
> install.packages('knitr')
Installing package into ‘/opt/homebrew/lib/R/4.1/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/knitr_1.37.tar.gz'
Content type 'application/x-gzip' length 895567 bytes (874 KB)
==================================================
downloaded 874 KB

* installing *source* package ‘knitr’ ...
** package ‘knitr’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
  there is no package called ‘glue’
Error: unable to load R code in package ‘knitr’
Execution halted
ERROR: lazy loading failed for package ‘knitr’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/knitr’
* restoring previous ‘/opt/homebrew/lib/R/4.1/site-library/knitr’

The downloaded source packages are in
        ‘/private/var/folders/yr/vrcclyl91kd_dg97yrqtwqz40000gn/T/Rtmp2ZuLCx/downloaded_packages’
Warning message:
In install.packages("knitr") :
  installation of package ‘knitr’ had non-zero exit status
>

install glue and install knitr

> install.packages('glue')
Installing package into ‘/opt/homebrew/lib/R/4.1/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/glue_1.6.0.tar.gz'
Content type 'application/x-gzip' length 110320 bytes (107 KB)
==================================================
downloaded 107 KB

* installing *source* package ‘glue’ ...
** package ‘glue’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang -I"/opt/homebrew/Cellar/r/4.1.2/lib/R/include" -DNDEBUG   -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include   -fPIC  -Wno-implicit-function-declaration  -c glue.c -o glue.o
clang -I"/opt/homebrew/Cellar/r/4.1.2/lib/R/include" -DNDEBUG   -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include   -fPIC  -Wno-implicit-function-declaration  -c init.c -o init.o
clang -I"/opt/homebrew/Cellar/r/4.1.2/lib/R/include" -DNDEBUG   -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include   -fPIC  -Wno-implicit-function-declaration  -c trim.c -o trim.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/homebrew/Cellar/r/4.1.2/lib/R/lib -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib -o glue.so glue.o init.o trim.o -L/opt/homebrew/Cellar/r/4.1.2/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
installing to /opt/homebrew/lib/R/4.1/site-library/00LOCK-glue/00new/glue/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (glue)

The downloaded source packages are in
        ‘/private/var/folders/yr/vrcclyl91kd_dg97yrqtwqz40000gn/T/Rtmp2ZuLCx/downloaded_packages’
> install.packages('knitr')
Installing package into ‘/opt/homebrew/lib/R/4.1/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/knitr_1.37.tar.gz'
Content type 'application/x-gzip' length 895567 bytes (874 KB)
==================================================
downloaded 874 KB

* installing *source* package ‘knitr’ ...
** package ‘knitr’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
Error : .onLoad failed in loadNamespace() for 'glue', details:
  call: NULL
  error: 'knit_engines' is not an exported object from 'namespace:knitr'
Error: unable to load R code in package ‘knitr’
Execution halted
ERROR: lazy loading failed for package ‘knitr’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/knitr’
* restoring previous ‘/opt/homebrew/lib/R/4.1/site-library/knitr’

The downloaded source packages are in
        ‘/private/var/folders/yr/vrcclyl91kd_dg97yrqtwqz40000gn/T/Rtmp2ZuLCx/downloaded_packages’
Warning message:
In install.packages("knitr") :
  installation of package ‘knitr’ had non-zero exit status
>

Best,

@yihui
Copy link
Owner

yihui commented Dec 21, 2021

That's really weird. knitr doesn't use glue. I don't know why your R is always trying to load glue. Do you have anything in your ~/.Rprofile that uses glue?

BTW, again, as I mentioned in my first reply, I strongly recommend that you install the cask r instead (brew remove r && brew install --cask r).

@cderv
Copy link
Collaborator

cderv commented Dec 21, 2021

Recent change in glue was to export the knitr engine
https://github.com/tidyverse/glue/blob/e9b08dd8aee6e0d5c5ab57520e219592ded849fb/R/zzz.R#L14-L20

but knitr::knit_engines is an exported object so I don't understand this issue

Error : .onLoad failed in loadNamespace() for 'glue', details:
call: NULL
error: 'knit_engines' is not an exported object from 'namespace:knitr'

knitr has glue as dependency through stringr, but again it should not be an issue during installation

> pak::pkg_deps_explain("knitr", "glue")
knitr -> stringr -> glue                                                   

Unless this creates somehow a weird conflicting loop but I can't reproduce.

Also when you are uninstalling, uninstalling packages don't forget to restart your R session.

You should retry all that with correct R version also - I don't use Mac so I don't know about that but I would trust the above ☝️

@jlduan
Copy link
Author

jlduan commented Dec 21, 2021

Hi @yihui and @cderv

Thanks for all your suggestions.

I reinstalled stringi & stringr. And after that, I was able to get knitr installed.

Thanks! Happy holidays.

@yihui
Copy link
Owner

yihui commented Dec 21, 2021

knitr has glue as dependency through stringr, but again it should not be an issue during installation

Oh I didn't notice that. I just looked at https://github.com/tidyverse/stringr/blob/5f48256b/DESCRIPTION#L21-L30 and I was impressed (although not surprised)... Now I tend to work on #1549 earlier next year.

@cderv
Copy link
Collaborator

cderv commented Dec 21, 2021

glue has been a dependency since a few years now (tidyverse/stringr@d2a0233), mainly for str_glue() and str_glue_data(). Could have been made a Suggest probably if not using this function.

But glue is part of base tidyverse and quite low level so it is expected to be in most packages from tidyverse and related.

stringr is really painful to install from source so I would just try to remove it for this purpose. If we don't have issue on performance.

Anyway, glad it works now @jlduan. I'll close this issue.

@cderv cderv reopened this Dec 21, 2021
@cderv cderv closed this as completed Dec 21, 2021
@cderv
Copy link
Collaborator

cderv commented Dec 21, 2021

😓 and... it was already closed 😅

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants