> For the complete documentation index, see [llms.txt](https://gitbook.bergelsonlab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.bergelsonlab.com/programming-info/computing-programming-guides/wip-new-computer-setup.md).

# New computer setup

Most of the computers in the lab have macOS so the instructions are currently for MacOS only. Once the need arises, the instructions for Windows/Linux will be added.

## Before we start

### Homebrew

Most of the installations in these instructions are done using the homebrew package manager for macOS/Linux (primarily macOS). A few notes about this:

* R should be installed using the installer from their website. Do not install it using homebrew. That's what is recommended by the R project (<https://mac.r-project.org/tools/>) and hopefully will lead to fewer errors when building packages from source which sometimes happens when you simply want to install a package or do `renv::restore()`. \
  Note: if you prefer to use rig (a utility that allows you to install different versions of R in parallel and switch between them; see <https://github.com/r-lib/rig>), that should be fine because rig downloads R binaries from r-project.org.
* Before installing a GUI program (R Studio, Visual Studio Code, SourceTree, Slack, etc.) using `brew install --cask <name-of-the-program>` check that it hasn't been installed yet by searching for it using Spotlight. In most cases, there shouldn't be a problem if you re-install a program using homebrew but let's not test this assumption.
* If you don't want to install GUI programs with homebrew and would rather download installers from the programs' website - go for it.
* We do recommend using `homebrew` for any CLI programs (git, mambaforge/conda, GitHub CLI, etc.). `homebrew` will make sure that they are added to PATH and have a higher priority than

## Change default terminal shell to bash

{% hint style="info" %}
The reason we prefer bash is because it is the most commonly used shell and so when you google an error the instructions are particular to bash and won't work in zsh (the default macOS shell).
{% endhint %}

Run in a terminal:

```bash
chsh -s /bin/bash
```

Once done, close the terminal.

## Someone with admin rights (might be the user)

{% hint style="info" %}
I don't actually know whether admin rights are necessary for all of these.
{% endhint %}

* Install [homebrew](https://brew.sh/) that will help us install other programs without admin rights.
  * The web page linked above has a command prominently featured on it. Copy it, paste it into a terminal, and hit Enter.
  * The script will ask you for your password and to agree to something a few times. That's to be expected. Give it the password, agree to everything.
  * At the very end, it will tell you to "\[r]un these two commands in your terminal to add Homebrew to your PATH" followed by two lines of terminal commands. Copy both of those lines starting with a parenthesis and closing with a double quote, paste them into the same terminal, and run them.
* Install [R](https://cran.r-project.org/bin/macosx/). There are two versions: arm64 and x86. Click on the Apple logo in the top left corner and then on "About this Mac". Look at the line where it says what chip you have: if it says "M1"/"M2"/"M3" - install arm64 R, if it says "intel" - install the other one.
* Install [RStudio](https://posit.co/download/rstudio-desktop/): `brew install --cask rstudio`

## User

#### Install Google Chrome (if not already installed)

#### Install blabr

In an R console (open RStudio or run `R` in the terminal)

* <pre class="language-r"><code class="lang-r">install.packages('remotes')
  <strong>remotes::install_github('bergelsonlab/blabr')
  </strong></code></pre>

#### Python (and conda):

```bash
brew install mambaforge  # (or install Anaconda if that's what you prefer)
conda init
```

Close and re-open the terminal. There should be `(base)` prepended to the prompt line now.

#### blabpy

```bash
pip install blabpy
```

#### All things git

* `brew install git`  Even though MacOS comes with git preinstalled, it comes with an outdated version.
* `brew install gh` - GitHub CLI tools that make authenticating on GitHub easier.
* [Set up Gi](/programming-info/computing-programming-guides/git-and-github/set-up-github.md)tHub. (skip on shared computers)
* Install SourceTree: `brew install --cask sourcetree`

#### Building R packages (even if you aren't planning to develop R packages).

Follow instructions at <https://mac.r-project.org/tools/> to install "Mandatory tools".

Note: the `xcode-select` part might tell you that the command line tools have already been installed - that's alright, skip to the next step.

#### Other software

* Install Slack: `brew install --cask slack`
* Install VS Code as code/text editor and tell git to use it:
  * `brew install --cask visual-studio-code`
  * `git config --global core.editor "code --wait"`
* Install ELAN 6.3 from [the page with the previous versions](https://archive.mpi.nl/tla/elan/previous). Use the `M1.dmg` link if you have an M1/M2/M3 processor and the `.dmg` one if you have Intel. Do not install the latest version! We have had bad experience (bugs, slow speed) with the versions newer than 6.3. It is possible that the very latest version has all of that fixed but until we've tested that, please stick to 6.3.

#### Adjust finder settings

* View -> Show Path Bar. The path to the current folder should appear at the bottom of the window.
* Finder > Settings, then click Advanced. Select “Show all filename extensions.”

## Suggestions

* Install iTerm2 - replacement for the built-in terminal.
* Install R package `renv` and use it to have per-project R environments with their own independent sets of packages and R versions.
* Install rig (<https://github.com/r-lib/rig>) to switch between R versions.
* To work with Python, get a JetBrains license (free for students and researchers) and install PyCharm. Also, consider using DataSpell for mixed R/Python workflow and just as a more lightweight alternative.
* Get a GitHub Education account (free for students and researchers), sign in in PyCharm/DataSpell and install GitHub Copilot
* Install quarto - RMarkdown reincarnation from RStudio developers.
* Install kdiff3 and set it up as git difftool and mergetool. Alternative, use git tools within PyCharm/DataSpell.

### TODO

Consider other software choices for:

* Git visual diff and merge. kdiff3 is just something Zhenya was used to. There must be something that doesn't feel so dated.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.bergelsonlab.com/programming-info/computing-programming-guides/wip-new-computer-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
