rinternet-connection

R can't access to the internet on user level but on sudo level


As described, I tried install.packages(), getURL() as well as other several internet related fucntions, all failed to access to internet (no matter in commandline or RStudio). However, if I do system("ping 1.1.1.1"), it does transmit packages. On the other side, using sudo su and then R can access to the internet without any problem. So I only can install packages on sudo level.

Also tried switching to phone hotspot network, failed as well.

No proxy enabled.

R version: 4.2.0 System: Ubuntu 20.04 LTS 64-bit

Edit: connection error shows below:

> install.packages("abc")
Warning in install.packages :
  unable to access index for repository https://cloud.r-project.org/src/contrib:
  cannot open URL 'https://cloud.r-project.org/src/contrib/PACKAGES'
Installing package into ‘/home/kuai/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository https://cloud.r-project.org/src/contrib:
  cannot open URL 'https://cloud.r-project.org/src/contrib/PACKAGES'
Warning in install.packages :
  package ‘abc’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

Solution

  • Wrong proxy settings in export