Skip to contents

Save the six THIP_DB_* connection variables in a user-level .Renviron file and set them in the current R process. Run this inside your remote THIP account, not on the PC used to submit jobs. No Jupyter API token is involved.

Usage

thip_setup(
  host = Sys.getenv("THIP_DB_HOST"),
  port = Sys.getenv("THIP_DB_PORT", "8123"),
  database = Sys.getenv("THIP_DB_NAME", "thip"),
  user = Sys.getenv("THIP_DB_USER"),
  password = Sys.getenv("THIP_DB_PASSWORD"),
  scheme = Sys.getenv("THIP_DB_SCHEME", "http"),
  overwrite = FALSE,
  verify = TRUE,
  path = Sys.getenv("R_ENVIRON_USER", "~/.Renviron")
)

Arguments

host

Database hostname; defaults to THIP_DB_HOST.

port

HTTP port; defaults to THIP_DB_PORT or 8123.

database

Database name; defaults to THIP_DB_NAME or thip.

user

Database username; defaults to THIP_DB_USER.

password

Database password; defaults to THIP_DB_PASSWORD.

scheme

Either http or https; defaults to THIP_DB_SCHEME or http.

overwrite

Replace existing THIP entries? Defaults to FALSE.

verify

Verify the connection before saving? Defaults to TRUE.

path

User environment file. Defaults to R_ENVIRON_USER when set, otherwise ~/.Renviron. Its parent directory must exist. Keep it outside project repositories. A custom path needs corresponding R startup setup.

Value

The saved file path, invisibly; never the credentials or a connection.

Details

Existing THIP entries require overwrite = TRUE; unrelated lines are preserved. The complete file is replaced atomically with permissions 0600 on Unix (including Linux and macOS). Symbolic-link targets are refused. These are plaintext credentials protected by file permissions, not encryption. Processes running as this user and privileged administrators can read them.

Missing host/user values are prompted for interactively. A missing password uses IRkernel's masked getPass input, or the optional askpass package in another interactive R frontend. Unsupported, cancelled or unattended input fails without writing. Never type a real password as a notebook-cell literal. Arguments also accept values already obtained from a trusted configuration.

Normal R startup loads the saved file. A project .Renviron, an explicit R_ENVIRON_USER, architecture-specific startup files, or --no-environ / --vanilla can change that behavior. Configure the intended startup path before launching R, or explicitly use readRenviron(path) in an existing session. This function does not modify .Rprofile or install startup hooks.

Verification uses the same SELECT-only connection check as thip_connect() and disconnects afterward. Failed verification leaves the file and process environment unchanged. verify = FALSE saves syntactically valid settings without contacting the DB; it does not establish that they work.

First run in a THIP notebook

Run thip_setup() once, in a notebook cell inside your THIP account. You will see, in order:

  1. Two text prompts: Database host: and then Database username:. The port (8123), database (thip) and scheme (http) use their defaults and are not prompted. Values already set as THIP_DB_* variables are not asked for.

  2. A masked Database password: box; typed characters show as dots. The password is never requested in an unmasked prompt.

  3. A short pause while a read-only SELECT check connects and then disconnects.

  4. One line: "THIP configuration saved with owner-only permissions and loaded in this session."

Six THIP_DB_* lines are then saved to ~/.Renviron with permissions 0600. Later sessions need only thip_connect(). A first run looks like this, with placeholders in angle brackets:

thip_setup()
#> Database host: <host provided by the THIP team>
#> Database username: <your database username>
#> Database password: (masked box)
#> THIP configuration saved with owner-only permissions and loaded in this session.

Troubleshooting

Message or symptomMeaning and what to do
"THIP configuration already exists"Setup was done before; it appears before any prompt. Use thip_connect(), or thip_setup(overwrite = TRUE) to replace the saved values.
"THIP connection verification failed"The host, username or password is wrong, or the database is unreachable. Nothing was saved; run thip_setup() again.
"host must be a hostname without a URL, path or credentials"Enter only the host name, without http://, a port or a path.
"Input unavailable or cancelled"A prompt was cancelled or could not be shown, for example outside an interactive notebook cell. Nothing was saved; run setup in a notebook cell.
No masked password box outside JupyterIn RStudio or a terminal, install the askpass package for masked entry.

Examples

if (FALSE) { # \dontrun{
# Once, inside THIP; enter credentials through prompts, not cell literals.
thip_setup()
# In this session or subsequent sessions with normal R startup:
con <- thip_connect()
DBI::dbDisconnect(con)
} # }