Skip to content
Browse files

BUG: Fix R updater function

- For some reason the exported bash function has trouble scoping the
  exported variable, so pass it explicitly as a function parameter.

- Create R_LIBS_USER directory if necessary.

- Correct printf expansion of R packages.

- Fix various typos.

- Use setwd() because we are spawning R in the /root directory.  This
  more robust that relying on `su - $user`.

- Enable echo for debugging.
  • Loading branch information
pan14001 committed Aug 15, 2016
1 parent 264ed80 commit e06845aa03a077579f3f571277461fe3d7f64a38
Showing with 11 additions and 7 deletions.
  1. +11 −7
@@ -34,10 +34,15 @@ python_install_packages() {

r_install_packages() {
local pkgs=\"$(sprintf "\",%s\"" "${r_pkgs[@]}")\"
R --quiet -vanilla -e <<EOF
local pkgs=$@
pkgs=\"$(printf "\",\"%s" $pkgs)\"
Rscript --vanilla - <<EOF
options(echo = TRUE)
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)

@@ -50,10 +55,9 @@ main () {
# Install R libraries in the user home directory so that updating
# the libraries later on does not triggering the "unwritable
# directory" warning.
export r_pkgs
export -f r_install packages
su cgi_user -c "bash -c r_install_packages"
unset r_pkgs r_install_packages
export -f r_install_packages
su cgi_user -c "bash -c \"r_install_packages ${r_pkgs[*]}\""
unset r_install_packages


0 comments on commit e06845a

Please sign in to comment.
You can’t perform that action at this time.