RStudio Connect QuickStart - install.packages() Issue

I'm trying to test out RS Pro ODBC drivers, and require odbc installed.

It fails on install.packages("odbc"), regardless of repos used, as follow:

> install.packages("odbc", repos = "https://cloud.r-project.org/")
Warning in install.packages :
  unable to access index for repository http://localhost:5000/packages/cran/latest/src/contrib:
  cannot open URL 'http://localhost:5000/packages/cran/latest/src/contrib/PACKAGES'
Warning in install.packages :
  unable to access index for repository http://localhost:5000/packages/internal/latest/src/contrib:
  cannot open URL 'http://localhost:5000/packages/internal/latest/src/contrib/PACKAGES'
Installing package into ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/3.5’
(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 ‘odbc’ is not available (for R version 3.5.1)
> ?install.packages
Warning: unable to access index for repository http://localhost:5000/packages/cran/latest/src/contrib:
  cannot open URL 'http://localhost:5000/packages/cran/latest/src/contrib/PACKAGES'
Warning: unable to access index for repository http://localhost:5000/packages/internal/latest/src/contrib:
  cannot open URL 'http://localhost:5000/packages/internal/latest/src/contrib/PACKAGES'
> options("repos" = "https://cloud.r-project.org/")
> getOption("repos")
[1] "https://cloud.r-project.org/"
> install.packages("odbc", repos = "https://cloud.r-project.org/")
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/rstudio/R/x86_64-pc-linux-gnu-library/3.5’
(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 ‘odbc’ is not available (for R version 3.5.1)

Thanks for sharing this!! I think the problem you're running into here is that you are in an offline environment, and so you do not have access to the internet. Honestly, I'm pretty surprised that it was not even able to access the RSPM URL (http://localhost:5000/packages/cran/latest/src/contrib/PACKAGES). Ultimately, RSPM will not be much use because even if RSP could access RSPM, RSPM will not be able to get packages from the internet. Perhaps the problem there is that your RSPM license is not activated, due to being offline?

That said, we will definitely add odbc to our next pass at the QuickStart! We definitely want the drivers to be usable!

How do you normally install R packages in your infrastructure? Do you have an internal CRAN mirror? If you have access to the internet somewhere else, you can always download the source code for the package, SSH it into the QuickStart, and then install things that way. That gets pretty tedious if you have to install dependencies and such too, though.

Alternatively, if you have an outbound HTTP_PROXY set, you can configure that within the QuickStart so that package installation can reach the internet.

2 Likes

All the licenses are now activated, and install.packages() works as designed; thanks @cole!

...wondering if this is a trap by design :smirk:

rstudio@rstudio-quickstart:~$ sudo /opt/rstudio-pm/bin/license-manager status
RStudio License Manager 1.2.1329-3

-- Local license status --

Trial-Type: Verified
Status: Evaluation
Days-Left: 46
License-Scope: System

-- Floating license status --

License server not in use.
rstudio@rstudio-quickstart:~$ t/rstudio-connect/bin/license-manager status
-bash: t/rstudio-connect/bin/license-manager: No such file or directory
rstudio@rstudio-quickstart:~$ sudo /opt/rstudio-connect/bin/license-manager status
RStudio License Manager 1.2.502-1

-- Local license status --

Trial-Type: Verified
Status: Evaluation
Days-Left: 35
License-Scope: System

-- Floating license status --

License server not in use.
rstudio@rstudio-quickstart:~$ sudo /usr/lib/rstudio-server/bin/license-manager status
RStudio License Manager 1.2.1335-1

-- Local license status --

Trial-Type: Verified
Status: Evaluation
Days-Left: 41
License-Scope: System

-- Floating license status --

License server not in use.

> install.packages("odbc")
Installing package into ‘/home/rstudio/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘magrittr’, ‘assertthat’, ‘prettyunits’, ‘bit’, ‘pkgconfig’, ‘rlang’, ‘DBI’, ‘Rcpp’, ‘blob’, ‘bit64’, ‘hms’, ‘BH’

trying URL 'http://localhost:5000/packages/cran/latest/src/contrib/magrittr_1.5.tar.gz'
Content type 'application/x-gzip' length 200957 bytes (196 KB)
==================================================
downloaded 196 KB

.
.
.
.

On a separate note, is there a guide to set outbound HTTP_PROXY?

Is this similar to the steps you showed for SSH into VM?

This will be useful in case one needs to install from packages not in CRAN.

:rofl: Definitely an unintentional trap... but maybe one that we don't mind :laughing: RSPM was born out of challenging customer offline environments, where package provisioning and management was one of the key problems for RSP / RSC servers, where arbitrary user code is being executed and needs package dependencies. One exciting new feature that the QuickStart does not yet showcase for RSPM is package binaries (for CRAN), which we describe a bit here: Faster package installs on Linux with Package Manager beta release

Setting HTTP_PROXY is often done just by setting environment variables. I.e. HTTP_PROXY=someurl:8080 HTTPS_PROXY=someurl:8080 curl -i -v https://cran.rstudio.com.

However, setting them for other software can be a bit tricky, depending on the software. We have specific guidance for Connect and RSPM:

https://docs.rstudio.com/connect/admin/package-management.html#proxy-configuration
and
https://docs.rstudio.com/rspm/admin/outbound-proxy.html

In RSP, I think this normally just takes the form of /etc/profile or ~/.bashrc or /etc/environment or something of that nature. You could also set these types of variables inside of ~/.Rprofile, Rprofile.site, , ~/.Renviron, Renviron.site, etc. in the R configuration.

It's worth noting that sometimes setting HTTP_PROXY, etc. can cause trouble, because certain URLs require the outbound proxy to be reached (i.e. cran.rstudio.com), where others cannot be reached from the outbound proxy (i.e. localhost or other internal infrastructure, on occasion). Basically, proxies can be painful.

If you do need to install packages not in CRAN, you can also add them to RSPM if you want :smile:

https://docs.rstudio.com/rspm/admin/repositories.html#git-sources

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.