Error in installing devtools in Rstudio, "installation of package ‘devtools’ had non-zero exit status"

I'm tring to install "devtools" package in my ubuntu20.04 LTS from last one week. I've tried many ways including full deletion of R and Rstudio from my ubuntu virtual box. But nothing is working and it's kinda frustrating. I also installed libssl-dev but I don,t know where is the problem happening.
The installation command I use in Rstudio is,

if (!requireNamespace("devtools", quietly = TRUE)) install.packages("devtools")

Here are some screenshots from the Rstudio interface,

And the terminal code error is,

> install.packages("devtools")
Installing package into ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/devtools_2.4.5.tar.gz'
Content type 'application/x-gzip' length 374718 bytes (365 KB)
==================================================
downloaded 365 KB

* installing *source* package ‘devtools’ ...
** package ‘devtools’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error: package or namespace load failed for ‘usethis’:
 package ‘usethis’ was installed before R 4.0.0: please re-install it
Execution halted
ERROR: lazy loading failed for package ‘devtools’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/devtools’

The downloaded source packages are in
	‘/tmp/Rtmp9P2hbP/downloaded_packages’
Warning message:
In install.packages("devtools") :
  installation of package ‘devtools’ had non-zero exit status
> 


Please someone help me. How would I able to use devtools in my Rstudio? Please!!! :disappointed_relieved::disappointed_relieved::disappointed_relieved:

And there is these types of error in background jobs,

ERROR: loading failed
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/reprex’
ERROR: dependency ‘hms’ is not available for package ‘progress’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/progress’
ERROR: dependencies ‘blob’, ‘dplyr’ are not available for package ‘dbplyr’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/dbplyr’
ERROR: dependency ‘dplyr’ is not available for package ‘dtplyr’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/dtplyr’
ERROR: dependency ‘scales’ is not available for package ‘ggplot2’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/ggplot2’
ERROR: dependency ‘gargle’ is not available for package ‘googledrive’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/googledrive’
ERROR: dependency ‘selectr’ is not available for package ‘rvest’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/rvest’
ERROR: dependency ‘dplyr’ is not available for package ‘tidyr’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/tidyr’
ERROR: dependencies ‘hms’, ‘progress’ are not available for package ‘vroom’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/vroom’
ERROR: dependencies ‘dplyr’, ‘tidyr’ are not available for package ‘broom’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/broom’
ERROR: dependencies ‘gargle’, ‘googledrive’ are not available for package ‘googlesheets4’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/googlesheets4’
ERROR: dependency ‘progress’ is not available for package ‘readxl’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/readxl’
ERROR: dependencies ‘broom’, ‘tidyr’ are not available for package ‘modelr’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/modelr’
ERROR: dependencies ‘hms’, ‘vroom’ are not available for package ‘readr’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/readr’
ERROR: dependencies ‘hms’, ‘readr’ are not available for package ‘haven’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/haven’
ERROR: dependencies ‘broom’, ‘dbplyr’, ‘dplyr’, ‘dtplyr’, ‘ggplot2’, ‘googledrive’, ‘googlesheets4’, ‘haven’, ‘hms’, ‘modelr’, ‘readr’, ‘readxl’, ‘reprex’, ‘rvest’, ‘tidyr’ are not available for package ‘tidyverse’
* removing ‘/home/nihad/R/x86_64-pc-linux-gnu-library/4.2/tidyverse’

The downloaded source packages are in
	‘/tmp/RtmpMBb4GZ/downloaded_packages’


✔ Packages successfully installed.
There were 33 warnings (use warnings() to see them)

And also these types of packages error,

Error: package ‘vctrs’ was installed before R 4.0.0: please re-install it
Execution halted
Error: package ‘ellipsis’ was installed before R 4.0.0: please re-install it
Execution halted
Error: package or namespace load failed for ‘reprex’:
 .onLoad failed in loadNamespace() for 'reprex', details:
  call: NULL
  error: package ‘withr’ was installed before R 4.0.0: please re-install it
Error: loading failed
Execution halted
[17/19] Installing rvest...
Error: package ‘stringr’ was installed before R 4.0.0: please re-install it
Execution halted
Error: package ‘vctrs’ was installed before R 4.0.0: please re-install it
Execution halted
type or paste code here

What to do? Anyone?

This is complaining about packages in your library that have been compiled for an older R version. After a major R upgrade you need to recompile your packages for that version. Run this command

update.packages(checkBuilt = TRUE, ask = FALSE)

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.