0

I try to install whatever package as follows in R (regardless if it is R 4.0 or R 4.2):

install.packages("brms")

and this

install.packages("brms", lib = "path/win-library")

I get this:

* installing *source* package 'brms' ...
** package 'brms' successfully unpacked and MD5 sums checked
** using staged installation
** R
Warning: namespace 'brms' is not available and has been replaced
by .GlobalEnv when processing object 'brmsfit_example1'
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called 'shiny'
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
ERROR: lazy loading failed for package 'brms'
* removing 'C:/Users/Documents/R/win-library/4.0/brms'
Warning in install.packages :
  installation of package ‘brms’ had non-zero exit status

The downloaded source packages are in
    ‘C:\Users\AppData\Local\Temp\Rtmp0IDKze\downloaded_packages’

But, when I then want to load it into R it does not exist and I get an error:

library(brms)
Error in library(brms) : there is no package called ‘brms’

I do not even see the folders containing brms in either of the .libPaths(). I have tried to unzip the downloaded folder brms in the temporary folder to the libPaths, but that does not work either.

I have searched the internet but have not found a proper solution. What should I do to change it? All my packages do not work.

Phil
  • 7,287
  • 3
  • 36
  • 66
Thomas
  • 441
  • 3
  • 16
  • Your package is not installed, you probably missed error messages during installation. – jay.sf Oct 17 '22 at 15:29
  • I get an error that the `shiny` package cannot be called, and the lazy loading fails. See edit, please. – Thomas Oct 18 '22 at 07:33
  • 1
    I guess something gets loaded in RStudio during startup. Try to uncheck _Tools > Global options > Workspace > Restore .RData_ and set _Save workspace_ to never. You can also try to install brms w/o RStudio in the console; open a cmd and type `R.exe`, R should open, then just `install.packages('brms')` and see what happens. – jay.sf Oct 18 '22 at 07:47
  • 1
    When you are doing the installation step, look at `print(.libPaths())` and note the first directory. It is the default target. Check (via `cmd.exe` or Windows Explorer) that it was indeed written -- it very likely was. Next, when you fire up R check `print(.libPaths())` again. It may now be different because you may have two different configuration settings. You need to straighten set that. I often recommend to use an explicit library path (say: `C:/opt/R/library`) that also persists when you update R. – Dirk Eddelbuettel Oct 18 '22 at 14:15

0 Answers0