Skip to content

Commit

Permalink
Re-enable the local CRAN variant (#3)
Browse files Browse the repository at this point in the history
* Rename to setup-centos7...

* Re-enable the local CRAN setup

* Directly use package name in environment modifications

Switches from using the package name as a symbol to having it remain as a character.

* Clarity of install.packages() shim functionality

- Emphasize this shim will only work in R GUI or terminal.
- RStudio overrides the `install.packages()` function with its own variant to keep its package panel up to date.
- The only way to modify RStudio's override is to have the user trigger it via a package load or function call after RStudio has been fully initialized.

For more details, see: rstudio/rstudio#4498

* Spacing
  • Loading branch information
coatless committed Mar 23, 2019
1 parent 6e1d263 commit 40ef9bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
30 changes: 16 additions & 14 deletions .Rprofile
Expand Up @@ -38,21 +38,20 @@
## Initialize an empty local CRAN repository.
## Note: In this setup, we are not placing package
## sources or binaries into this location.

# local_user_cran = file.path(Sys.getenv("HOME"), "cran")
# dir.create(local_user_cran, showWarnings = FALSE)
local_user_cran = file.path(Sys.getenv("HOME"), "cran")
dir.create(local_user_cran, showWarnings = FALSE)

## Set the location of packages to the empty local CRAN.
## Ensure that the appropriate RStudio Secure warning is handled.

# options(repos = c("CRAN" = paste0("file://", local_user_cran)))
options(repos = c("CRAN" = paste0("file://", local_user_cran)))

## CBTF Help Messages ----

## Hard coded help documentation location
cbtf_help_url = "https://cbtf.engr.illinois.edu/home.html"
## TODO: Update to where docs are on the CBTF website!!

cbtf_help_url = "https://cbtf.engr.illinois.edu/home.html"

## Open the URL for students to view help documentation
help_cbtf = function(url = cbtf_help_url) {
message("Opening help documentation at: ", url)
Expand Down Expand Up @@ -105,21 +104,24 @@
env = as.environment(pkg_env_name)
#pkg_ns_env = asNamespace(pkgname)

# Retrieve symbolic value of function/value to be replaced
sym = as.symbol(name)

# Unlock environment where the function/variable is found.
base:::unlockBinding(sym, env)
base::unlockBinding(name, env)

# Make the assignment into the environment with the new value
base:::assign(name, value, envir = env)
base::assign(name, value, envir = env)

# Close the environment
base:::lockBinding(sym, env)
base::lockBinding(name, env)
}

## Rewrite install.packages
shim_pkg_func("install.packages", "utils", function(...) { cbtf_disabled_cran_msg() })
## Provide an alternative install.packages(...) routine
install_packages_shim = function(...) { cbtf_disabled_cran_msg() }

## Setup a shim
##
## Note: RStudio will overwrite the shim due to the initialization procedure.
## Only valid in _R_ terminal sessions or R GUI.
shim_pkg_func("install.packages", "utils", install_packages_shim)

## Display the welcome bumper
cbtf_welcome_msg()
Expand Down
6 changes: 3 additions & 3 deletions r-centos7-install.sh → setup-centos7-r.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

#
# r-centos7-install.sh
# setup-centos7-r.sh
#
# Copyright (C) 2019 James Joseph Balamuta <balamut2@illinois.edu>
#
Expand All @@ -24,10 +24,10 @@

######################################
# # Allow the file to execute
# chmod +x ~/r-centos7-install.sh
# chmod +x ~/setup-centos7-r.sh
#
# # Run the file
# ./r-centos7-install.sh
# ./setup-centos7-r.sh
######################################

############## Add Development Tools
Expand Down

0 comments on commit 40ef9bf

Please sign in to comment.