Rstudio-server fails to start with database error

We are using the ondemand app setup for rstudio that works with rstudio 1.3.1093-1. We are trying to get the new rstudio 2021.09.2 and when we launch the app it fails with no errors in the output.

The launch from the script file is as follows:
–www-port “${port}”
–auth-none 0
–auth-pam-helper-path “${RSTUDIO_AUTH}”
–auth-encrypt-password 0
–rsession-path “${RSESSION_WRAPPER_FILE}”
–server-data-dir “${TMPDIR}”
–secure-cookie-key-file “${TMPDIR}/rstudio-server/secure-cookie-key”
–server-user “$USER”

When we run the command run the command line we get the following error with filling in the variables:
2022-02-02T00:07:25.255149Z [rserver] ERROR database error 7 (sqlite3_statement_backend::loadOne: attempt to write a readonly database) [description: Could not delete expired revoked cookies from the database, description: Could not read revoked cookies from the database]; OCCURRED AT virtual rstudio::core::Error rstudio::core::database::Connection::execute(rstudio::core::database::Query&, bool*) src/cpp/core/Database.cpp:517; LOGGED FROM: int main(int, char* const*) src/cpp/server/ServerMain.cpp:791

Has anyone else seen this issue?

Try adding something like this to your file above your rserver command:

# Generate a database.conf file
export DBCONF="${PWD}/database.conf"
umask 077
sed 's/^ \{2\}//' > "${DBCONF}" << EOL
  # set database location
chmod 700 "${DBCONF}"

Then add this to your rserver command:

  --database-config-file "${DBCONF}" 

We use a container, so we mount in a bunch of /etc/ configurations - like the one you can inline in @maflister’s example.

This database configuration being one.

Also I just added a reference of rserver's --help output to my own app’s README. It takes way to long to look up --database-config-file in RStudio docs for me - so it’ll be a nice reference for me. I would suggest folks doing the same if you maintain an Rstudio app.

I tried the edit to the script file and it comes up with a login prompt. Our old rstudio setup never prompted for a username and password.

Can you share the total content of your file and your template/bin/auth file?

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 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] Module to load: <%= context.r_version %>"
echo " [from] Loaded modules:" && module list

Start RStudio Server

PAM auth helper used by RStudio

export RSTUDIO_AUTH="${PWD}/bin/auth"

Generate an rsession wrapper script

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}” “${@}”

Set working directory to home directory

cd “${HOME}”


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

chmod 700 “${DBCONF}”


RSTUDIO_PASSWORD=“password” /usr/lib/rstudio-server/bin/rserver
–www-port “${port}”
–auth-none 1
–auth-pam-helper “/var/lib/rstudio-server/”
–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

Confirm password environment variable exists

if [[ -z ${RSTUDIO_PASSWORD} ]]; then
echo “The environment variable RSTUDIO_PASSWORD is not set”
exit 1

Read in the password from user

read -s -p "Password: " PASSWORD
echo “”

if [[ ${USERNAME} == ${USER} && ${PASSWORD} == ${RSTUDIO_PASSWORD} ]]; then
echo “Successful authentication”
exit 0
echo “Invalid authentication”
exit 1

That error has to do with the cairo package and R/Rstudio not being able to find it somehow.

Here’s a similar topic.

I found this hack I put into a container to fix the issue

RUN echo "options(bitmapType='cairo')" > /usr/local/lib64/R/etc/

I’m reaching out to my apps group to see what flags they pass when they build R and Rstudio.

You can check for cairo support in your R by running capabilities() command in an R prompt. If it is false, then install cairo (OS package is easiest) and recompile R including the --with-cairo flag.

Cairo was true when I checked capabilities.

That’s great! As @jeff.ohrstrom said, adding options(bitmapType='cairo') to the file is the potential fix. That’s what we use at my site.

I’m not finding a in our installation of R on our 4.1.2 setup. We have R set up as a package on our cluster.

But I found it in another version and copied it over. plots now working great!

If you have a vanilla install, will not be present. If you found /usr/local/lib64/R/etc, which is likely if you have a package manager install, you can create the file. If you have a non-standard install path, you’ll need to look for the lib64/R/etc path in your R install root.

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