RStudio cannot find install.packages on Linux (Manjaro, Arch)

Hi, It's as the title says, for some reason, RStudio can't find the install.packages function, or at least, that's what it says. If I run install.packages("package"), it's clearly there and runs but fails, midway through. Here's an example (happens with other packages I tried too):

> install.packages("xml2")
Installing package into ‘/home/ydeng/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
trying URL ''
Content type 'application/x-gzip' length 271876 bytes (265 KB)
downloaded 265 KB

Loading local functions ...Error in install.packages("httr") : 
  could not find function "install.packages"
Calls: source ... eval -> eval -> source -> withVisible -> eval -> eval
Execution halted
Warning in install.packages :
  installation of package ‘xml2’ had non-zero exit status

The downloaded source packages are in

Interestingly enough, if I run the command in a normal terminal running R, it works fine after prompting for selecting a secure CRAN mirror.

Any help is appreciated!

So I noticed that it was complaining about the httr package no matter which package I told it to install, so I manually installed httr and that fixed it. If anyone can explain this to me, I'd appreciate it. I know httr is used in the .Rprofile.

1 Like