# CRAN mirror (pkg.shecan.ir)

> Mirror of CRAN (cloud.r-project.org) for R: source packages (also archived versions), Windows and macOS binary packages, R installers and the Ubuntu/Debian apt repositories of R.

- Upstream: cloud.r-project.org
- Mirror URL: <https://mirror-cran.pkg.shecan.ir>
- Clients: r, rstudio, apt
- Service status: <https://pkg.shecan.ir/status.json> (key `cran`; up/down, refreshed every minute)
- Guide (Persian, HTML): <https://pkg.shecan.ir/mirrors/cran/>
- JSON: <https://pkg.shecan.ir/api/v1/mirrors/cran.json>

## Limitations

- Only CRAN; Bioconductor, R-universe and Posit Package Manager (Linux binary packages) are not mirrored.
- Windows and macOS binary packages are cached for up to 7 days; CRAN sometimes rebuilds a binary under the same version.
- Package files, indexes and R installers only: Rtools, manuals, web pages and directory listings are not served.

## Setup

Every block below is the exact text of the Persian guide. Unless marked otherwise it is run against the live mirror in a disposable container on every catalog change; "checked by hand" blocks cannot run in a container. Change a machine only with its owner's permission: back up existing configuration first, merge into existing files instead of overwriting them, and keep the "Undo" step at hand.

### r, rstudio: persistent (user- or system-wide configuration)

Run

```
cat('options(repos = c(CRAN = "https://mirror-cran.pkg.shecan.ir"))\n', file = "~/.Rprofile", append = TRUE)
```

Undo / restore the default (linux, macos)

```sh
sed -i.bak '/mirror-cran\.pkg\.shecan\.ir/d' ~/.Rprofile
```

### r, rstudio: temporary (one command or the current shell; nothing saved)

Run

```
install.packages("jsonlite", repos = "https://mirror-cran.pkg.shecan.ir")
```

### apt: persistent (user- or system-wide configuration)

Run (linux)

```sh
wget -qO- https://mirror-cran.pkg.shecan.ir/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
echo "deb https://mirror-cran.pkg.shecan.ir/bin/linux/ubuntu $(. /etc/os-release && echo $VERSION_CODENAME)-cran40/" | sudo tee /etc/apt/sources.list.d/cran-r.list
sudo apt update
sudo apt install -y --no-install-recommends r-base
```
