StirlingCodingClub / studyGroup

Gather together a group to skill-share, co-work, and create community
http://StirlingCodingClub.github.io/studyGroup/
Other
2 stars 1 forks source link

R Packages gone wonky #36

Open mattnuttall00 opened 5 years ago

mattnuttall00 commented 5 years ago

Hi all,

Yesterday I tried to install a new package, and was confronted with the option:

Do you want to install from sources the packages which need compilation? y/n

I didn't really know what that meant, so I said yes (I now realise that was the incorrect option to choose...). The package appeared to install, but then at the end of some unusual white script (which I was not familiar with when installing a package - I assume related to selecting yes above), I noticed the line:

installation of package had non-zero exit status

I tried to load the package via library(), but I was told that the package didn't exist. So I assumed the installation hadn't worked, but the package was just for interest and not essential to what I was doing, and so I ignored it and carried on with my work. Only to discover that all of the packages I had currently loaded in my R session had stopped working.

So I closed down my Rstudio session, re-opened, and tried to re-load my packages. None of them loaded. So I closed down R studio, opened the R console, and ran update.packages(). I then re-opened R studio, and all of the packages appear to load now, except tidyverse. When I try to load it, I get the following messages:

`ERROR: dependency 'rlang' is not available for package 'lifecycle'

Based on the above, it looks like some of the dependencies are failing to load. I have tried to install some of the mentioned dependencies (for tidyverse) such as dplyr independently, and I keep getting the option: Do you want to install from sources the packages which need compilation? which I have never seen before when installing/loading these packages. I have tried both y and n, and neither option successfully installs the packages.

I'm now out of ideas - this is beyond my knowledge. Any suggestions most welcome!!

Cheers Matt

jejoenje commented 5 years ago

Woohoo! Welcome to dependency hell!

Good grief! That is quite a mess indeed! What package was it that you originally tried to install? It certainly doesn't seem to play nice with much other stuff... Did it come from CRAN??

Installing from "sources" just means that you are compiling raw code, as opposed to something that was already compiled for your system (Linux, Windows, Mac, whatever you're running). Generally speaking that is not a bad idea at all, as you should be getting something that's custom-compiled for your system (and existing package combination). However I suppose there are more things that could go wrong (evidently!) if different combinations with existing packages are a little iffy. Oopsy!

Anyway, do I understand correctly that currently, everything seems to be working as it should except tidyverse? If so, I think what I would try first, is to remove it and at least some of its dependencies ('dplyr', 'hms', 'purrr', 'tibble', 'tidyr' - possibly leave 'rlang' unless you really have to remove it).

remove.packages("dplyr")
remove.packages("hms") # etc

Then try to reinstall tidyverse:

install.packages("tidyverse")

If you have to compile from source, do, but that would suggest you have a wider issue, I think.

Have you removed the package that originally messed things up in the first place, by the way? If not, I would start with that.

What version of R are you on? Try sessionInfo(). It may be that actually uninstalling R completely (and remove all packages), reinstalling the latest version, and then installing all your packages again as you need them - especially if you are on an older version of R, that might be the best/easiest way forward?

mattnuttall00 commented 5 years ago

Grrr, how annoying! I can't even remember what the package was, as it's not in my library as it didn't install properly. But it was off GitHib, not CRAN.

I'm on R vers 3.4.0, and I see that the latest version is 3.6.1. Perhaps the simplest thing to do would be to uninstall R and reinstall, and then as you say, just install packages as I go along.

Best way to uninstall R? Do I just run the unins000.exe file in C>Program Files>R>R-3.4.0? Will that get rid of the package library automatically?

Thanks!

jejoenje commented 5 years ago

Issue with packages off Github (or other sources) is that obvs they haven't gone through all the stringent checks that CRAN imposes. Which are partly to do with exactly these sorts of potential issues...

Yea if you are due an upgrade anyway, I would probably do that. It's not as bad as it sounds. You might as well do RStudio at the same time, too, if you need to.

It's been a while since I have done this on Windows, but I think that as long as you go through the "official" uninstall procedures (probably cleanest to do this through "System > Install remove/Software" or whatever they are calling it now), it should remove everthing correctly. Reboot after you've done it, and check to see if there is anything left in the installation directories - if so, chuck that out too. Then remove RStudio, reboot again, download new versions of both R and RStudio, and install. Once all is up and running I would probably just install every package one by one as you need it - rather than try to reinstall everthing in one go I mean.

mattnuttall00 commented 5 years ago

OK perfect, I will just do that. It sounds cleaner that trying to faff around with different bits of tidyverse. I could probably use the upgrade anyway!

Thanks @jejoenje !