R: "internet routines cannot be loaded" when starting from RStudio

300 views Asked by At

I am running Red Hat Enterprise Linux (RHEL) 8.5 with Linux kernel 4.18 and Gnome 3.32.2. In this system, I've got R 4.1.2 compiled with the tool asdf with shared libraries enabled. On top of that, I installed RStudio 2021.09.01-372 from an RPM from the official RStudio website.

When I start Rstudio, the first line of output after the usual R startup is an error:

Error in tools::startDynamicHelp() : internet routines cannot be loaded

I am unable to figure out what's causing this error, and with it I can't run things like refresh CRAN or update packages. But if I start a pure R session from the terminal (instead of Rstudio) this error does not occur.

Some things I tried:

Install the krb5 and libssh2 packages on my host system: Didn't help.

Starting a "pure" R session (both with and without the --vanilla argument) from the Terminal tab within Rstudio also gives this error. If I try to run update.packages() from this session, it pops up a window to select a CRAN mirror then fails with the following:

Warning: failed to download mirrors file (internet routines cannot be loaded); using local file '/home/[my username]/.asdf/installs/R/4.1.2/lib64/R/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cloud.r-project.org/src/contrib:
  internet routines cannot be loaded
Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
  unable to load shared object '/home/penyuan/.asdf/installs/R/4.1.2/lib64/R/modules//internet.so':
  /lib64/libssh.so.4: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b

But like I said, the strange thing is if I start an R session outside of Rstudio, these errors don't happen.

Within RStudio, the only workaround I can find is to run this command upon startup (suggested in this thread):

options(download.file.method="wget")

Once this is done, everything else seems to work, such as package updates.

However, I don't want to manually do this every time I start RStudio. So I tried to put it into ~/.Rprofile including a test print() as follows:

print("This is `~/.Rprofile`")
options(download.file.method="wget")

When I open RStudio, I can see the output from the print() call, but the options() command is not run because the original error shows up again. I still have to manually enter options(download.file.method="wget") every time.

I also tried to fold everything into a .First function in ~/.Rprofile as follows:

.First <- function() {
    options(download.file.method="wget")
    print("This is the `.First` function in `~/.Rprofile`")
}

Unfortunately, same result as before: print()'s output is seen, but options() is not run.

I also made sure that my ~/.Rprofile includes a trailing newline as discussed here. But this didn't help.

The above are the steps I've tried so far.

Why does this error only occur when running RStudio or a terminal within Rstudio? Why doesn't it happen if I start R from a terminal outside of Rstudio?

Is there a way to solve the problem so that the error doesn't happen in the first place? If it can't be solved, how do I set up my ~/.Rprofile so that options(download.file.method="wget") will be run?

Thank you.

0

There are 0 answers