After doing some extensive reading on the web and trying a few things we now can launch the 2021.09 version and run R commands. However, unlike the prior version 1.3.1093 we cannot run a plot such as hist(mtcars$mpg)
We get the error message:
Error in RStudioGD() :
Shadow graphics device error: r error 4 (R code execution error)
In addition: Warning message:
In grDevices:::png("/tmp/RtmpGBrHIj/f0e5ed5dee574bcb8008f07d0242a974.png", :
unable to open connection to X11 display "
I have not been able to track down anything on that issue yet. The following are copies of our script.sh.erb file and our template/bin/auth:
#!/usr/bin/env bash
Load the required environment
setup_env () {
Additional environment which could be moved into a module
Change these to suit
export PATH="$PATH:/usr/lib/rstudio-server/bin"
module load <%= context.r_version %>
module load anaconda3
echo " [from script.sh.erb] Module to load: <%= context.r_version %>"
echo " [from script.sh.erb] Loaded modules:" && module list
}
setup_env
Start RStudio Server
PAM auth helper used by RStudio
export RSTUDIO_AUTH="${PWD}/bin/auth"
Generate an rsession
wrapper script
export RSESSION_WRAPPER_FILE="${PWD}/rsession.sh"
(
umask 077
sed ‘s/^ {2}//’ > “${RSESSION_WRAPPER_FILE}” << EOL
#!/usr/bin/env bash
Log all output from this script
export RSESSION_LOG_FILE="${PWD}/rsession.log"
exec &>>"${RSESSION_LOG_FILE}"
Launch the original command
echo “Launching rsession…”
set -x
exec rsession --r-libs-user “${R_LIBS_USER}” “${@}”
EOL
)
chmod 700 “${RSESSION_WRAPPER_FILE}”
Set working directory to home directory
cd “${HOME}”
hostname
export TMPDIR="$(mktemp -d)"
mkdir -p “$TMPDIR/rstudio-server”
python -c ‘from uuid import uuid4; print(uuid4())’ > “$TMPDIR/rstudio-server/secure-cookie-key”
chmod 0600 “$TMPDIR/rstudio-server/secure-cookie-key”
set -x
Launch the RStudio Server
echo “Starting up rserver for $USER…”
Generate a database.conf file
export DBCONF="${PWD}/database.conf"
(
umask 077
sed ‘s/^ {2}//’ > “${DBCONF}” << EOL
set database location
provider=sqlite
directory=${TMPDIR}/rstudio-server/db
EOL
)
chmod 700 “${DBCONF}”
DISABLE_AUTH=true
RSTUDIO_PASSWORD=“password” /usr/lib/rstudio-server/bin/rserver
–server-daemonize=0
–www-port “${port}”
–auth-none 1
–auth-pam-helper “/var/lib/rstudio-server/rstudio_auth.sh”
–auth-encrypt-password 0
–rsession-path “${RSESSION_WRAPPER_FILE}”
–server-data-dir “${TMPDIR}”
–database-config-file “${DBCONF}”
–secure-cookie-key-file “${TMPDIR}/rstudio-server/secure-cookie-key”
–server-user “$USER”
#!/usr/bin/env bash
Confirm username is supplied
if [[ $# -lt 1 ]]; then
echo “Usage: auth USERNAME”
exit 1
fi
USERNAME="${1}"
Confirm password environment variable exists
if [[ -z ${RSTUDIO_PASSWORD} ]]; then
echo “The environment variable RSTUDIO_PASSWORD is not set”
exit 1
fi
Read in the password from user
read -s -p "Password: " PASSWORD
echo “”
if [[ ${USERNAME} == ${USER} && ${PASSWORD} == ${RSTUDIO_PASSWORD} ]]; then
echo “Successful authentication”
exit 0
else
echo “Invalid authentication”
exit 1
fi