I'm failing to update ggplot2, any suggestions please?!

In R Studio on my Mac, I've been trying to update ggplot2 from 2.2.1 to 3.1.0 in order to use ggtern. Unfortunately this keeps going round in circles and not working, and I'm a beginner who just doesn't know what to try next! I am using the newest version of R Studio.

I've tried

update.package("ggplot2") which resulted in

Error in update.packages(ggplot2) : object 'ggplot2' not found

And I've tried to update packages from the Output pane. That got into a loop where R Studio asked me to restart R because one or more package to be updated is currently loaded and R needs to restart prior to making the updates. I ended up stopping the loop by not restarting, which then appeared to run an install but ended:

Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status

I'm afraid that I don't really know how best to explain what I'm seeing, or communicate this in the forum, but I'm hoping I can get a pointer in the right direction. Ultimately I need to make some ternary diagrams, hence my wish to use ggtern...

Here's what typically works for us:

  • remove.packages(ggplot2)
  • Restart R (under "Session" menu in RStudio)
  • devtools::install_git("git://github.com/tidyverse/ggplot2.git")

Warning: When installing a package from github in this way, you might need to install newer versions of other packages. Always be ready to play a bit of "Whack-A-Mole..."


Thank you.

I'll start with ggplot2 then, and hope that I understand any other messages I get about other packages!

You might also find success with:

  • remove.packages(ggplot2)
  • Restart R (under "Session" menu in RStudio)
  • install.packages("https://cran.r-project.org/src/contrib/ggplot2_3.2.0.tar.gz", repo=NULL, type="source")

Repeat for each dependency that needs updating (ie "R Whack-A-Mole")

OK, I understand the difference between GitHub and cran so I can see how those lines work. Thanks.

Just a thought: when I began with R Studio, I installed the Tidyverse, of which ggplot2 is a part, so can I do something at that level 'globally' rather then having to wrangle individual packages?

If removing tidyverse as a package successfully removes the component packages, then re-installing tidyverse from source might bring in everything new.

The problem we sometimes run into is that an R installation will only bring in the most recent version of a package known to work with that version of R, not the newest known version of the package. Thus we often need to "force" R to bring in newer versions via source-based installs. I'm not sure how a tidyverse install handles this (ie I'm not sure if installing tidyverse from source actually installs the component packages from source).

I see. Well in that case I will start with ggplot2 and go from there.

You have been very helpful, thank you!

Oh well I tried today, and it seems that getting the more recent version of ggplot2 requires a newer version of rlang.

So I also tried to remove the older rlang and replace with a newer, but I couldn't make that work either.

And in the process I seem to have completely removed ggplot2 from my system, and I've tried to reinstall but it doesn't seem to be working:

Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in

Unfortunately I don't know what that means!

What happens if you just run the following:


I've tried that a couple of times, but the details in the console then always end with this:

Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in

In the list of packages, I can see ggplot2 (version 2.2.1), but the check box next to it is unticked. I've tried to install from the packages list too, but same result.

Could you post the whole error message? you are omiting the useful parts

Of course, here we are (sorry, I'm new to R this is well outside my comfort zone!):


There is a binary version available but the source version is later:
binary source needs_compilation
ggplot2 3.1.0 3.2.0 FALSE

installing the source package ‘ggplot2’

trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.2.0.tar.gz'
Content type 'application/x-gzip' length 3193995 bytes (3.0 MB)

downloaded 3.0 MB

Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
unknown timezone 'zone/tz/2019a.1.0/zoneinfo/Europe/London'

  • installing source package ‘ggplot2’ ...
    ** package ‘ggplot2’ successfully unpacked and MD5 sums checked
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** inst
    ** preparing package for lazy loading
    Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
    namespace ‘pkgconfig’ 2.0.1 is being loaded, but >= 2.0.2 is required
    ERROR: lazy loading failed for package ‘ggplot2’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ggplot2’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ggplot2’
    Warning in install.packages :
    installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in

This is telling you that you have to update this package dependency, try installing it first with


If everything goes well, then you can try to install ggplot2 again, but this time try with this command

install.packages("ggplot2", dependencies = TRUE)

Well that seems to have worked!

I don't understand the huge lines of content that ran through the console while it was working, but I can now see a more recent version of ggplot2 in my packages list (hurrah! that means I should be able to load ggtern) and I just loaded ggplot2 and ran one of my histograms and it worked a dream.

Thank you very much, this means a great deal to me. With more practice and experience I can only become more proficient in R, but it's support of people who know what they are doing that makes it possible.

I'm glad I could help If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

I've done just that.

Unfortunately I now have a related problem, trying to access ggtern. Does this (below) mean that I first need to get the package 'robust base' before being able to use ggtern?

Error: package or namespace load failed for ‘ggtern’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘robustbase’
In addition: Warning message:
package ‘ggtern’ was built under R version 3.4.4

yes, you are starting to get it

Right! So I use install.package() for that I think.

Just to add a note here, usually you don't need to install the dependencies separately. install.packages defaults to dependencies = NA, i.e. c("Depends", "Imports", "LinkingTo"). If you use TRUE (as Andres did in his solution above), it adds Suggests to the aforementioned list.

Since it seems that it doesn't seem to work for you, and you received this warning message, I think that there's a chance your R version is outdated. You can update it to the latest version 3.6.1, which will probably be useful.

Thank you for explaining that. I'm using R Studio (and I'm in the most recent version of that), because that's how R was introduced to me. What does that mean I have to do if I want to make use of ggtern?