RStudio Setup

There are 2 primary versions of RStudio available for staff in PHS, a local version on your machine and as an IDE on the Posit Workbench server. If your working on your local machine, first R and RStudio must be installed. Just as with Git, if you work within PHS, these can be requested through Service Now. Once authorised, this will allow you to download it from the Software Center on your machine. Most use cases will be for the server but getting Git setup on RStudio is the same regardless of where you’re using it.

  1. Once in RStudio, go to Tools in the menu bar > Global Options > Git/SVN:

 

  1. If “Git executable:” shows “(none)”, click “Browse” and select the Git executable installed on your system. - That’s it for attaching RStudio and Git. This will allow you to utilise the RStudio Git GUI tools inside R Projects.

    • On Windows - the file path should point to folder Git was installed to and finish .../bin/git.exe.
    • On the server - the path should be /usr/bin/git.

Authentication for remotes

Authentication is required to work with Git remotes, e.g., GitHub. Gitea uses HTTPS authentication, with SSH not available, and accepts your standard LDAP username and password. As such, there is no setup required for Gitea.

  • Create an SSH Key - this is the recommended authentication method on the new server, as a faster and more convenient method.

    1. If you see anything within the ‘SSH RSA Key:’ box, you can skip this step, else click on ‘Create RSA Key…’, click ‘Create’ and close the dialog box that appears confirming the key creation.
    2. Now, click on ‘View public key’ and copy the text string that appears in a dialog box.
    3. Go to your GitHub SSH Settings and click ‘New SSH key’.
    4. Give the key a meaningful title that you will recongnise (e.g. “Posit Workbench”) and paste the key from RStudio. Complete the process by clicking ‘Add SSH key’.

 

  • Use HTTPS on GitHub - GitHub blocked plain HTTPS authentication due to security concerns, and as such now requires a PAT. While SSH is now available (and the preferred option), details are below for how to use:

    1. Create a PAT - Go to your GitHub Personal Access Tokens’ settings page, create a token (with a meaningful name), and grant the necessary permissions (likely to be all of ‘repo’). Then, copy the given token to your clipboard. Note: for security, after you leave the page, you will no longer be able to retrieve the token.
    2. Use the PAT - the PAT will be used in place of your password when performing secure operations over HTTPS. It is possible to store the PAT rather than having to enter for every operation:
      1. If you already have cached these details or have made an error, clear the cache by entering this command in the terminal:

        git config --global -–unset credential.helper

      2. Then enter this command in the terminal. After performing a Git operation, you will be asked to enter your credentials. Make sure to use your usual GitHub username and the PAT. Following this, your credentials should be stored for future Git operations.

        git config --global credential.helper store