generated from berkeley-dsep-infra/hub-user-image-template
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rprofile.site
36 lines (31 loc) · 1.68 KB
/
Rprofile.site
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Use RStudio's CRAN mirror to get binary packages
# 'latest' just means it has all available versions.
# We can specify version numbers in devtools::install_version
options(repos = c(CRAN = "https://packagemanager.rstudio.com/all/__linux__/jammy/latest"))
# RStudio's CRAN mirror needs this to figure out which binary package to serve.
# If not set properly, it will just serve up source packages
# Quite hilarious, IMO.
# See https://docs.rstudio.com/rspm/admin/binaries.html
# UPDATE: see the newer setting below...
#options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os)))
# If install.packages() is run from an RStudio console, it downloads binaries.
# If it is run from an RStudio terminal, from a Jupyter terminal, or from a
# Jupyter R notebook, it downloads source. Setting the user agent to the string
# below sets it to be binary. This may improve image build times.
# If it works, it'd be better to dynamically set the R version as above, and
# also the RStudio Server version if possible.
options(HTTPUserAgent = "RStudio Server (2024.04.2.764); R (4.4.1 x86_64-pc-linux-gnu x86_64 linux-gnu)")
## Source extra Rprofile files.
#
# This lets us easily add new code via extraFiles (or other z2jh-related
# magic) without having to rebuild the image each time.
# Get a list of files in the directory
rprofile_dir <- "/etc/R/Rprofile.site.d/"
rprofile_files <- list.files(rprofile_dir, full.names = TRUE)
# Source each file
for (rprofile_file in rprofile_files) {
cat("Sourcing:", rprofile_file, "\n")
source(rprofile_file)
}
# Don't keep temporary variables in environment
rm(rprofile_dir, rprofile_files, rprofile_file)