I am running RStudio under Ubuntu Linux version 20.04.
I have the longstanding problem that the install.packages() command will not install or update dependencies. This means I have to spend hours, sometimes six or seven hours, installing packages and all of their dependencies, and all of their dependencies' dependencies, and so on.
I've tried using the depdencies = TRUE flag, and it is ignored. I've tried using also using the lib = library_path flag and that also makes no difference.
I'm wondering if the problem is that I have multiple libraries in .libPaths(). I read somewhere that this can prevent dependencies from being installed, because R doesn't know where you want to put them. Could this be the problem?
I don't want multiple libraries in .libPaths(). I'd like to just have one.
Does anyone have any advice? I've had this problem for years, and it's un-google'able.
I'm most interested in specific code (in R or in the terminal window) that can get the job done and fix my problem, rather than general suggestions. My coding and unix shell skills are good but not as expert as many of you.
I have not seen this problem here before and unless someone has run across it, it will be hard to make specific suggestions without more information. Having multiple libraries on .libPaths() is normal, so I can't see how that would cause this problem.
I suggest you go to the CRAN list of packages (CRAN Packages By Name) and pick one you don't have and that has at least one dependency that you don't have. The abc package looked like a decent candidate, but you may see something better. Start a new R session and run
I'm no expert on this but it looks like some of your packages are up to date but were installed under an older version of R and must be reinstalled. What version of glue do you have? The latest is 1.6.2 and it was released 2022-02-24. If you have upgraded from R 3.x to R 4.x since then, you need to reinstall glue. I think R 4.0.0 came out in April 2020. Did you stay on R3.x for a while?
The remove.packages() function needs to know what library to find the package in. My glue is in /usr/local/lib/R/site-library and I'll be curious to know if yours is in the same place.
I think that's right, but the problem is it's not just one package. When I go to install glue, it has dependencies that also are outdated, and I get the same errors that those need to be reinstalled. In the end, I have to manually reinstall around 100 packages one-by-one. It's a horrible mess. Why can't R automatically reinstall those dependencies? Shouldn't dependencies = TRUE take care of it recurrsively?
If it's an issue of R not knowing what library to install glue, then that's why I was trying to delete the extra paths. I just want one place where R looks for everything.
I confess to being especially frustrated, because R does not experience these problems on Mac or PC. When I upgraded to R 4.0 on my Mac, I simply re-installed tidyverse, and R automatically reinstalled any dependencies that were out-of-date. These problems are only experienced in the Linux environment.
This will take a while. Do it from the R console, not RStudio (or you'll get the silly "one or more opened ... want new session" prompt that is actually only for the benefit on Windows users).
Alternatively, see the r2u package, which will give you binaries. Very quickly. ALL of them. With system library dependencies as well. All by the guy who has been lead on all things related to Debian on R for over 20 years. Read carefully the instructions at GitHub - eddelbuettel/r2u: CRAN as Ubuntu Binaries and skip the optional step 5. It should pick-up everything in your to_reinstall except for some oddball and stuff not on CRAN. Then you can compare the installed.packages() with the saved list.
I got into your pickle because for a long time apt update lagged badly and I took up installing from source.
Thank you very much @technocrat. It works!!! This is The Way.
I adapted your instructions a bit to make it work for my setup. Notes:
Please note: I had to replace https:// links with xxxx:// because I am a new user and therefore not allowed to post links. When you use these instructions, replace xxxx:// with https://
Then I re-installed R and Rstudio:
xxxx://youtu.be/eE1zh0YVMeM?si=kRfHJRoLywAkg1hR
Then I installed the r2u package according to the instructions, more or less:
xxxx://github.com/eddelbuettel/r2u
Note that the main page has instructions for Ubuntu 22.04. If you want instructions for Ubuntu 20.04, see:
xxxx://github.com/eddelbuettel/r2u/blob/master/inst/scripts/add_cranapt_focal.sh
Some modifications to those instructions were needed:
a) Anywhere you see "apt", you must change it to "sudo apt". And I do mean everywhere. Or else you get a fatal error and the whole thing stops. For instance:
Notice that "sudo" is added in two different places to the same line of script! One addition is in the middle of the script. Don't miss those or the whole thing will fail!
You may want to just do a find-and-replace to identify all the instances of "apt" to replace with "sudo apt" so that you don't inadvertently miss any.
b) Any time you see "echo" you must replace it with "sudo bash -c 'echo PUT THE REST OF IT IN HERE'"
for instance:
Note the open ' and closed ' symbols that were added.
c) Do not skip the optional step 5. I found this step to be crucial. Specifically, install the bspm package.
9) Then open R from the terminal (not via Rstudio!). You do this by simply opening a terminal window and typing:
R
Set the R working directory to the directory where you saved your list of installed packages in step #1, above.
Enable the bspm package, so that you can install R packages using the binaries rather than source. In R, type:
bspm::enable()
Now, also in R, re-install all those packages you used to have. Note: I had to adapt @technocrat's code slightly at this step, because a column index was needed. Also, I used dependencies = TRUE as a belt-and-suspenders type of thing to make sure R would catch the dependencies and not freak out.