---
title: "Installation"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{installation}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r include = FALSE}
library(WebGestaltR)
```

---

### Requirements

- Rust 1.66.0 or later (GNU version if on Windows)
- R 4.0.0 or later (Windows requires 4.2+)

#### System dependencies on Linux

Installing from source on Linux additionally requires development headers for the system
libraries used by WebGestaltR's dependencies. On Debian or Ubuntu:

```bash
sudo apt-get install libssl-dev libxml2-dev libcurl4-openssl-dev \
    libfontconfig1-dev libfreetype6-dev libharfbuzz-dev libfribidi-dev \
    libpng-dev libtiff5-dev libjpeg-dev
```

`libharfbuzz-dev` and `libfribidi-dev` are needed by `systemfonts` and `textshaping`, which the
required `svglite` package depends on. Without them, `svglite` fails to install and WebGestaltR
reports it as a missing dependency. On Fedora or RHEL the equivalents are `openssl-devel`,
`libxml2-devel`, `libcurl-devel`, `fontconfig-devel`, `freetype-devel`, `harfbuzz-devel`,
`fribidi-devel`, `libpng-devel`, `libtiff-devel` and `libjpeg-turbo-devel`.

Windows and macOS users installing a binary from CRAN do not need any of this.

---

Since WebGestaltR v1.0.0, Rust is used for core computations in the R package. Therefore, to install WebGestaltR, please download and install Rust from [https://rust-lang.org/tools/install/](https://rust-lang.org/tools/install/). For Mac, Linux, or Unix users, Rust can be installed from the command line, and Windows users can download a GUI installer. **If using Windows**: please make sure to install the `GNU` version of Rust. This will be an option when you run the installer. 

**For Windows Users**: Install the `gnu` version of Rust, not the `MSVC` version. The Rust installer will ask for the version you want to download.

Restart your terminal after installing Rust to ensure the Rust compiler is available in your path. You can check that Rust is installed correctly by running `rustc --version` in your terminal.

After installing Rust, you can install WebGestaltR by running the following command in an R session:

```R
# install.packages("devtools") # run if devtools not already installed
devtools::install_github("bzhanglab/WebGestaltR")
```

During installation, the Rust compiler will be called to build the computation library used by WebGestaltR. If you run into problems with installation of the new version, please [open a new issue](https://github.com/iblacksand/WebGestaltR/issues/new?assignees=iblacksand&labels=Installation&projects=&template=installation-issue.md&title=).
