Strange tidyverse installation

Few days ago, in order to change my library path, I referred to a video and added a function to RStudio.
Here is the video:
How do I change the default library path for R packages [Set R environment at start up permanently] - YouTube
I added a function as the video recommended (2:11) to Rprofile.site.

.First <- function(){
	.libPath("C:/Program Files/R/R-4.1.0/library")
}

After add this function, I could install my packages in the administrator mode.
However, when I install tidyverse, it came out:

also installing the dependency ‘rvest’


  There is a binary version available but the
  source version is later:
      binary source needs_compilation
rvest  1.0.0  1.0.1             FALSE

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/tidyverse_1.3.1.zip'
Content type 'application/zip' length 430056 bytes (419 KB)
downloaded 419 KB

package ‘tidyverse’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\levih\AppData\Local\Temp\RtmpiQF53A\downloaded_packages
installing the source package ‘rvest’

trying URL 'https://cran.rstudio.com/src/contrib/rvest_1.0.1.tar.gz'
Content type 'application/x-gzip' length 94307 bytes (92 KB)
downloaded 92 KB

Error: cannot add binding of '.First' to the base environment
Execution halted
Warning in install.packages :
  installation of package ‘rvest’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\levih\AppData\Local\Temp\RtmpiQF53A\downloaded_packages’

I installed rvest again, and it came out:

> install.packages("rvest")

  There is a binary version available but the
  source version is later:
      binary source needs_compilation
rvest  1.0.0  1.0.1             FALSE

installing the source package ‘rvest’

trying URL 'https://cran.rstudio.com/src/contrib/rvest_1.0.1.tar.gz'
Content type 'application/x-gzip' length 94307 bytes (92 KB)
downloaded 92 KB

Error: cannot add binding of '.First' to the base environment
Execution halted
Warning in install.packages :
  installation of package ‘rvest’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\levih\AppData\Local\Temp\RtmpiQF53A\downloaded_packages’

The mesage Error: cannot add binding of '.First' to the base environment Execution halted mentioned my added function.

Why does the error come out?

It is actually not necessary to use the .First() function, you can delete that and simply add this line to the Rprofile.site file.

.libPaths(c("C:/Program Files/R/R-4.1.0/library"))

Then restart your R session and try to install rvest again.

Thank you so much.
It works.

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.