I am unable to install ggplot2 - installation of package ‘ggplot2’ had non-zero exit status

> install.packages("ggplot2")

  There is a binary version available
  but the source version is later:
        binary source needs_compilation
ggplot2  3.3.5  3.3.6             FALSE

installing the source package ‘ggplot2’

trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.3.6.tar.gz'
Content type 'application/x-gzip' length 3061989 bytes (2.9 MB)
downloaded 2.9 MB

* installing *source* package ‘ggplot2’ ...
** package ‘ggplot2’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Warning: The package `vctrs` (>= 0.3.8) is required as of rlang 1.0.0.
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace ‘vctrs’ 0.3.6 is being loaded, but >= 0.3.8 is required
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package ‘ggplot2’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/ggplot2’
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in

The immediate problem is that you need to update your vctrs package. You can do that by running


However, the earlier warning saying

There is a binary version available
  but the source version is later

may be a sign of other problems. Which version of R are you running? That is displayed when you start RStudio or R. The current version of R is 4.2.1. You may want to update to that if you are not already using it.

How do I update? I am a student and I have no idea what I am doing with RStudio. I currently have version 4.0.3

To update vctrs you can enter the code


in the console, which his usually the lower left pane of the Rstudio window.

Updating a package is done just like installing a package. However you are installing ggplot2, you can do the same thing with vctrs.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.