Closed bersbersbers closed 2 years ago
If you set such code in your .Rprofile
knitr::opts_knit$set(progress = FALSE)
It will load knitr package in each R Session, which means that its dependencies will also be loaded. and xfun is one of them. When a package is loaded, it could cause issue when installing it or its dependency in the same session.
I would suggest not doing this - it can definitely cause issue like this one when updating in a non vanilla session.
If you want to set a knitr option globally for all your session, know that there is another way described in ?knitr::opts_knit
: You can use option.
So doing
options(knitr.package.progress = FALSE)
would work.
By doing this, knitr won't be loaded.
Hope it helps
Thanks @cderv, that helps a lot on many levels. Here's a few more details:
options(knitr.package.progress = FALSE)
is much better - I was not aware of that..Rprofile
: knitr::opts_knit$set(progress = FALSE); install.packages("xfun")
also fails.loadNamespace("xfun"); install.packages("xfun")
loadNamespace("openxlsx"); install.packages("openxlsx")
fails.loadNamespace("ggplot2"); install.packages("ggplot2")
works.ERROR: cannot remove earlier installation, is it in use?
R
is smart enough in the case of library(xfun); install.packages("xfun")
Warning: package 'xfun' is in use and will not be installed
I am not sure if there is anything xfun
can and wants to do - if not, feel free to close this.
Yes I know it is not something specific to .Rprofile - it just amplifies. You will have the issue as soon as you are trying to install a package that is already loaded in the session. So it is best to always start in a fresh session to install packages. Usually that is what you do.
In gets pretty weird on windows too.
The solution to help with this is the pak package https://github.com/r-lib/pak It will try to be clever about loading and unloading package, and also detect the potential conflicts.
Anyway, it is not something to solve on a package basis. It is just the way R works - Good practice is to install / update only in a fresh session. But pak helps me a lot now with all this
By filing an issue to this repo, I promise that
xfun::session_info('xfun')
. 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/xfun')
.I understand that my issue may be closed if I don't fulfill my promises.
Here we go.
My
.Rprofile
:Then,
R -e 'install.packages("xfun")'
fails:Commenting out
knitr::opts_knit$set(progress = FALSE)
fixed the issue.