# RStudio Server Issues

**URL:** <https://discourse.openondemand.org/t/rstudio-server-issues/2063>\
**Category:** Get Help\
**Tags:** question\
**Created:** [May 12, 2022, 6:13pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063 "2022-05-12T18:13:56Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![brad.traver](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@brad.traver](https://discourse.openondemand.org/u/brad.traver)\
**Post date:** [May 12, 2022, 6:13pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/1 "2022-05-12T18:13:56Z")

</div>

I’m trying to deploy RStudio server without the use of Singularity. The following is my output.log file:

```auto
Script starting...
Waiting for RStudio Server to open port 5615...
/home/brad.traver
No Modulefiles Currently Loaded.
talon04
mkdir: cannot create directory ‘/tmp/run’: File exists
mkdir: cannot create directory ‘/tmp/lib’: File exists
++ date
+ echo 'Starting up rserver... at Thu May 12 13:06:39 CDT 2022'
Starting up rserver... at Thu May 12 13:06:39 CDT 2022
++ whoami
+ rserver --www-port 5615 --auth-none 0 --auth-pam-helper-path /bin/auth --auth-encrypt-password 0 --rsession-path /home/brad.traver/rsession.sh --server-data-dir=/tmp/run --secure-cookie-key-file /tmp/rstudio-server/secure-cookie-key --server-user=brad.traver
Timed out waiting for RStudio Server to open port 5615! on Thu May 12 13:08:43 CDT 2022
Cleaning up...

```

This is my script file:

```auto
#!/usr/bin/env bash

<%-
  session_dir = session.staged_root
%>

#
# Start RStudio Server
#
# PAM auth helper used by RStudio
export RSTUDIO_AUTH="$WORKING_DIR/bin/auth"
export WORKING_DIR=$HOME
echo $WORKING_DIR
# Generate an `rsession` wrapper script
export RSESSION_WRAPPER_FILE="$WORKING_DIR/rsession.sh"
(
umask 077
sed 's/^ \{2\}//' > "$WORKING_DIR/rsession.sh" << EOL
  #!/usr/bin/env bash

  # Log all output from this script
  export RSESSION_LOG_FILE="$WORKING_DIR/rsession.log"

  exec &>>"\${RSESSION_LOG_FILE}"
  set -x

  # rsession.sh doesn't share the same env as the outside script, so these
  # need to be set explicitly
  export R_LIBS_SITE="${R_LIBS_SITE}"
  export TZ="US/Eastern"

  env

  # Launch the original command
  echo "Launching rsession..."
  rsession --r-libs-user "${R_LIBS_USER}" "\${@}"
EOL
)
chmod 700 "$WORKING_DIR/rsession.sh"

# Output debug info
module list
hostname

# rstudio runtime stuff
mkdir "$TMPDIR/run"
mkdir "$TMPDIR/lib"

# server log directory in this job's working directory
mkdir -p "$WORKING_DIR/logs"

set -x
# Launch the RStudio Server
echo "Starting up rserver... at $(date)"

rserver --www-port "${port}" --auth-none 0 --auth-pam-helper-path "${RSTUDIO_AUTH}" --auth-encrypt-password 0 --rsession-path "${RSESSION_WRAPPER_FILE}" --server-data-dir="/tmp/run" --secure-cookie-key-file "${TMPDIR}/rstudio-server/sec$

```

I’m not sure what I’m missing here.

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [May 12, 2022, 7:04pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/2 "2022-05-12T19:04:24Z")

</div>

Hi and welcome!

One question I’d have is where are you when the `rserver` command is issued?

Looking at the OSC version here:

> <https://github.com/OSC/bc_osc_rstudio_server/blob/master/template/script.sh.erb#L162>

It may be as simple as making sure you are in the `$HOME` before issuing the `rserver` command.

Also, if you haven’t it may help to take a look at the README.md in that repo which goes over a non-singularity build’s prerequisites:

> **[GitHub - OSC/bc\_osc\_rstudio\_server: Batch Connect - OSC RStudio Server](https://github.com/OSC/bc_osc_rstudio_server#prerequisites)**
>
> Batch Connect - OSC RStudio Server. Contribute to OSC/bc\_osc\_rstudio\_server development by creating an account on GitHub.

Because I’m also not seeing any kind of bind mount for singularity in the `script` posted either.

---

<div class="post-metadata">

**Author:** ![brad.traver](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@brad.traver](https://discourse.openondemand.org/u/brad.traver)\
**Post date:** [May 12, 2022, 7:07pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/3 "2022-05-12T19:07:12Z")

</div>

It’s being issued at the end of the script. All of the prerequisites are installed as listed on the GitHub page.

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [May 12, 2022, 7:27pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/4 "2022-05-12T19:27:10Z")

</div>

I’m not sure they are. Your module list is saying there are no modules loaded so the prereqs likely aren’t there from a `module purge` somewhere maybe? In your `before.sh` possibly. We can see that here:

> [@brad.traver](#):
>
> `No Modulefiles Currently Loaded.`

At the least we should see R loaded. There should be some `module loads` in the script for the needed modules such as R.

Also, what version of Rstudio are you running?

I still am not sure where the `cd ${HOME}` is that you say is ran at the bottom of the script either.

This thread may be of some use to gather what you may need to set to run without singularity:

> [@RStudio when launched without Singularity is having strange troubles with authentication](https://discourse.openondemand.org/t/rstudio-when-launched-without-singularity-is-having-strange-troubles-with-authentication/1213/15):
>
> Here is what the working rstudio 1.1 HTML looks like: Which is different from the rstudio 1.3 HTML, could this be a problem with how we are passing the authentication credentials in?

---

<div class="post-metadata">

**Author:** ![brad.traver](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@brad.traver](https://discourse.openondemand.org/u/brad.traver)\
**Post date:** [May 12, 2022, 7:59pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/5 "2022-05-12T19:59:05Z")

</div>

R is not installed as a module. It’s installed as part of the compute node image. All of the necessary executables should be in $PATH. RStudio and RStudio Server are both version 2022.02.2+485. I’ve added cd $HOME to the top of the script but the same issue persists. I will go through the thread you sent.

---

<div class="post-metadata">

**Author:** ![brad.traver](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@brad.traver](https://discourse.openondemand.org/u/brad.traver)\
**Post date:** [May 13, 2022, 6:16pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/6 "2022-05-13T18:16:18Z")

</div>

I’ve resolved the other issues with my script. It is below:

```auto
#!/usr/bin/env bash

<%-
  session_dir = session.staged_root
%>

#
# Start RStudio Server
#
# PAM auth helper used by RStudio
cd $HOME
export RSTUDIO_AUTH="${PWD}/bin/auth"
# Generate an `rsession` wrapper script
export RSESSION_WRAPPER_FILE="${PWD}/rsession.sh"
echo $RSESSION_WRAPPER_FILE
(
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}"
  set -x

  # rsession.sh doesn't share the same env as the outside script, so these
  # need to be set explicitly
  export R_LIBS_SITE="${R_LIBS_SITE}"
  export TZ="US/Eastern"

  env

  # Launch the original command
  echo "Launching rsession..."
  rsession --r-libs-user "${R_LIBS_USER}" "\${@}"
EOL
)
chmod 700 "${PWD}/rsession.sh"

# Output debug info
hostname

# rstudio runtime stuff
export TMPDIR="$(mktemp -d)"

# server log directory in this job's working directory
mkdir -p "${PWD}/logs"

set -x
# Launch the RStudio Server
echo "Starting up rserver... at $(date)"

rserver --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/se$

```

The same problem persists.

```auto
Script starting...
Waiting for RStudio Server to open port 47969...
/home/brad.traver/rsession.sh
talon04
++ date
+ echo 'Starting up rserver... at Fri May 13 12:56:41 CDT 2022'
Starting up rserver... at Fri May 13 12:56:41 CDT 2022
++ whoami
+ rserver --www-port 47969 --auth-none 0 --auth-pam-helper-path /home/brad.traver/bin/auth --auth-encrypt-password 0 --rsession-path /home/brad.traver/rsession.sh --server-data-dir=/tmp/tmp.4DIcyRTg9U --secure-cookie-key-file /tmp/tmp.4DIcyRTg9U/rstudio-server/secure-cookie-key --server-user=brad.traver
Timed out waiting for RStudio Server to open port 47969! on Fri May 13 12:58:45 CDT 2022
Cleaning up...

```

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [May 13, 2022, 7:12pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/7 "2022-05-13T19:12:23Z")

</div>

A couple things. If you want to speed up debugging cycles, you can follow this pattern:

- Launch the job and watch it fail
- navigate to it’s session directory (where you’re finding those logs)
- At this point you can edit `script.sh` with what changes you want. (You’ll need to hard somethings like `port` and so on)
- Now you can run `script.sh` directly and it doesn’t redirect or background itself. You’ll issue `rserver` in the foreground and it _may_ tell you why it’s not starting.

Back to the RStudio issue - obviously it’s failing to start up, so that pattern above will help you get it running and at least trying to output to `stdout` what’s wrong. If it’s not saying anything in `stdout` then you may have to look at system logs that it’s writing (if it’s writing any).

We run RStudio container because (a) I want to override the /etc defaults (shown below so that I can change the `log-dir`) and (b) a system installed Rstudio really likes to write & read from system directories like /var and /etc. I dont’ know why or how many setting you’d need to change to get it to run, but you’ll probaby have to confer with the default settings and the configurations it may have installed in `/etc/rstudio`.

> <https://github.com/OSC/bc_osc_rstudio_server/blob/1ce2e4fb1ddb25921069a1e31cb3edc02ce90535/template/script.sh.erb#L144>

---

<div class="post-metadata">

**Author:** ![maflister](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/maflister/32/139_2.png) [@maflister](https://discourse.openondemand.org/u/maflister)\
**Post date:** [May 17, 2022, 1:25pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/8 "2022-05-17T13:25:42Z")

</div>

Not sure if this is the exact issue, but RStudio Server 1.4 and above require a `--database-config-file` option when launching rserver. You’ll find some info [here](https://github.com/mcw-rcc/bc_rcc_rstudio_server/tree/rstudio-1.4-updates).

---

<div class="post-metadata">

**Author:** ![brad.traver](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@brad.traver](https://discourse.openondemand.org/u/brad.traver)\
**Post date:** [May 18, 2022, 9:20pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/9 "2022-05-18T21:20:50Z")

</div>

After for further tweaking, I managed to get RStudio Server to start. When I click the “Connect to RStudio” button, the RStudio login page comes up with the following error:  
Error: Temporary server error. Please try again.

My script is below:

```auto
#!/usr/bin/env bash

<%-
  session_dir = session.staged_root
%>

#
# Start RStudio Server
#
# PAM auth helper used by RStudio
cd $HOME
export WORKING_DIR=${HOME}/r_working
export RSTUDIO_AUTH="$/home/brad.traver/ondemand/dev/rstudio/template/bin/auth"
# Generate an `rsession` wrapper script
export RSESSION_WRAPPER_FILE="${WORKING_DIR}/rsession.sh"
mkdir r_working
cd $WORKING_DIR
echo $RSESSION_WRAPPER_FILE
(
umask 077
sed 's/^ \{2\}//' > "$RSESSION_WRAPPER_FILE" << EOL
  #!/usr/bin/env bash

  # Log all output from this script
  export RSESSION_LOG_FILE="${WORKING_DIR}/rsession.log"

  exec &>>"\${RSESSION_LOG_FILE}"
  set -x

  # rsession.sh doesn't share the same env as the outside script, so these
  # need to be set explicitly
  export R_LIBS_SITE="${R_LIBS_SITE}"
  export TZ="US/Eastern"

  env

  # Launch the original command
  echo "Launching rsession..."
  rsession --r-libs-user "${R_LIBS_USER}" "\${@}"
EOL
)
chmod 700 "${WORKING_DIR}/rsession.sh"

# Output debug info
hostname

# rstudio runtime stuff
export TMPDIR="$(mktemp -d)"

# server log directory in this job's working directory
mkdir -p "${WORKING_DIR}/logs"

set -x
# Launch the RStudio Server
echo "Starting up rserver... at $(date)"

rserver --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=$(whoami) --database-config-file "/home/brad.traver/ondemand/dev/rstudio/template/etc/database.conf"

```

I think my issues might be caused by lack of configuration in the rsession and database config files. The database config file does have one line of configuration in it.

---

<div class="post-metadata">

**Author:** ![brad.traver](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@brad.traver](https://discourse.openondemand.org/u/brad.traver)\
**Post date:** [May 26, 2022, 8:54pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/10 "2022-05-26T20:54:20Z")

</div>

With help, I managed to figure it out. I seem to remember something about putting apps in /etc/ood/config/apps instead of /var/www/ood/apps/sys even though the docs say to put apps in /var/www/ood/apps/sys. @jeff.ohrstrom was that you? Can you clarify?

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [May 26, 2022, 9:06pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/11 "2022-05-26T21:06:26Z")

</div>

Sorry, in sum - deploy your apps to `/var/www` and your app configurations to `/etc/ood`.

- all apps are in `/var/www/ood/...`. We distribute apps, so they’ll get overwritten - the ones you write, even in that location, we don’t change or modify or anything.
- `/etc` is for configuration of those apps and we look at files there to _configure_ our apps, but never replace them.

---

<div class="post-metadata">

**Author:** ![brad.traver](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@brad.traver](https://discourse.openondemand.org/u/brad.traver)\
**Post date:** [May 26, 2022, 9:26pm UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/12 "2022-05-26T21:26:08Z")

</div>

I’m very confused now. Where should the scripts and forms be?

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [May 27, 2022, 12:11am UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/13 "2022-05-27T00:11:13Z")

</div>

` /var/www/ood/...`. We provide automation for puppet or ansible too.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)\
**Post date:** [November 23, 2022, 12:12am UTC](https://discourse.openondemand.org/t/rstudio-server-issues/2063/14 "2022-11-23T00:12:13Z")

</div>

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