Skip to content

Commit c798bc9

Browse files
committed
separate R and terminal code
1 parent 87777e4 commit c798bc9

File tree

2 files changed

+107
-80
lines changed

2 files changed

+107
-80
lines changed

working_documents/install_r_macos.Rmd

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ expand or collapse these sections.
1818

1919
### Set up R installation directory
2020

21+
If you do not have an existing version of R installed on your computer, download
22+
the installer for the latest release of R from the [CRAN macOS page](https://cran.r-project.org/bin/macosx/) and install this pre-built
23+
(binary) version with the default settings.
24+
2125
Open Terminal.app and follow these instructions:
2226

2327
1. Set `LOCAL` as a temporary environment variable to match your architecture
@@ -48,35 +52,53 @@ EOF
4852
<details><summary><i>Note if using RStudio terminal, or using Terminal.app on macOS < 10.15 (Catalina)...</i></summary> The code above assumes you are using a Zsh shell (the default on macOS &ge; 10.15). If you are using a bash shell, replace <code>.zprofile</code> with <code>.bash_profile</code>. The type of terminal in RStudio can be set in Terminal Options from the terminal or in Global Options.
4953
</details>
5054
</details>
51-
4. If you have previously installed R on the computer, make your account own the existing R framework folder
55+
4. Make your account own the R framework folder (created when installing R from
56+
the binary)
5257
```{sh}
5358
sudo chown -R $USER /Library/Frameworks/R.framework/
5459
```
55-
Otherwise, download the installer for the latest release of R from CRAN and install with the default settings first.
5660

5761
### Install prerequisites
5862

59-
1. Install Xcode Command Line Tools from the terminal
60-
```{sh}
61-
xcode-select --install
62-
```
63-
(If already installed, shows "xcode-select: error: command line tools are
64-
already installed").
65-
2. Install GNU Fortran (gfortran) from the binary at
66-
<https://mac.r-project.org/tools/>.
67-
3. Install XQuartz from the binary <https://www.xquartz.org/>.
68-
**Restart your computer** for XQuartz (and components that depend on it) to
69-
work!
70-
4. Within R, use the helper R script to install commonly required prerequisites
63+
For the following instructions, run the code within R:
64+
65+
1. Use the helper R script to install commonly required prerequisites
7166
```{r}
7267
source("https://mac.R-project.org/bin/install.R")
7368
install.libs("r-base-dev")
7469
```
75-
5. (Optional), within R, install Pango for full Cairo support
70+
2. (Optional), install Pango for full Cairo support
7671
```{r}
7772
install.libs("pango")
7873
```
79-
6. Check if you have a current version of MacTeX installed:
74+
3. Check if you already have Subversion installed:
75+
76+
```{r}
77+
system2("which", "svn")
78+
```
79+
80+
This will print a path where Subversion is installed. If nothing is
81+
printed, install Subversion:
82+
83+
```{r}
84+
install.libs("subversion", dep = FALSE)
85+
```
86+
87+
<details><summary><i>Troubleshooting...</i></summary> If this does not work, try installing Subversion via your preferred package manager, e.g. with Homebrew: <code>brew install svn</code>.
88+
</details>
89+
90+
For the remaining instructions, run the code within Terminal.app
91+
92+
1. Install GNU Fortran (gfortran) from the binary at
93+
<https://mac.r-project.org/tools/>. This version is prepared for specifically
94+
for R and will be used in preference to any other version on your system.
95+
2. From the terminal, install Xcode Command Line Tools
96+
```{sh}
97+
xcode-select --install
98+
```
99+
(If already installed, shows "xcode-select: error: command line tools are
100+
already installed").
101+
3. Check if you have a current version of MacTeX installed:
80102
```{sh}
81103
ls /usr/local/texlive
82104
```
@@ -85,25 +107,15 @@ ls /usr/local/texlive
85107
2022 2023 texmf-local
86108
```
87109
If this check doesn't show a subdirectory for the current year, install MacTex from the binary at <https://tug.org/mactex/mactex-download.html>.
88-
7. In the terminal, check if you already have Subversion installed:
89-
110+
4. Check if you have XQuartz installed:
90111
```{sh}
91-
which svn
112+
mdls -name kMDItemVersion /Applications/Utilities/XQuartz.app
92113
```
93-
94-
This will show a path where Subversion is installed, or `svn not found`.
95-
If necessary, install Subversion from within R:
96-
97-
```{r}
98-
install.libs("subversion", dep = FALSE)
99-
```
100-
101-
<details><summary><i>Troubleshooting...</i></summary> If this does not work, try installing via your preferred package manage, e.g. with Homebrew: <code>brew install svn</code>.
102-
</details>
103-
104-
8. (Recommended) If you are not already using a tool such as [rig](https://github.com/r-lib/rig)
105-
to install and manage multiple R versions, install RSwitch from <https://rud.is/rswitch/>. These tools are not part of the R Project, but
106-
make it easy to switch R versions.
114+
This will show the version number or `could not find /Applications/Utilities/XQuartz.app`. If missing, install XQuartz from the binary at <https://www.xquartz.org/>. **Restart your computer** for XQuartz (and components that depend on it) to work!
115+
5. (Recommended) If you are not already using a tool such as [rig](https://github.com/r-lib/rig)
116+
to install and manage multiple R versions, install RSwitch from <https://rud.is/rswitch/>. These are third-party tools, not part of the R
117+
Project, but are recommended here as they provide an easy way to switch R
118+
versions.
107119
108120
[//]: # (
109121
* Skip readline (use editline)

working_documents/install_r_macos.md

Lines changed: 62 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ to expand or collapse these sections.
99

1010
### Set up R installation directory
1111

12+
If you do not have an existing version of R installed on your computer,
13+
download the installer for the latest release of R from the [CRAN macOS
14+
page](https://cran.r-project.org/bin/macosx/) and install this pre-built
15+
(binary) version with the default settings.
16+
1217
Open Terminal.app and follow these instructions:
1318

1419
1. Set `LOCAL` as a temporary environment variable to match your
@@ -71,49 +76,72 @@ Open Terminal.app and follow these instructions:
7176
</details>
7277
</details>
7378
74-
4. If you have previously installed R on the computer, make your
75-
account own the existing R framework folder
79+
4. Make your account own the R framework folder (created when
80+
installing R from the binary)
7681
7782
``` sh
7883
sudo chown -R $USER /Library/Frameworks/R.framework/
7984
```
8085
81-
Otherwise, download the installer for the latest release of R from
82-
CRAN and install with the default settings first.
83-
8486
### Install prerequisites
8587
86-
1. Install Xcode Command Line Tools from the terminal
88+
For the following instructions, run the code within R:
8789
88-
``` sh
89-
xcode-select --install
90-
```
90+
1. Use the helper R script to install commonly required prerequisites
9191
92-
(If already installed, shows “xcode-select: error: command line
93-
tools are already installed”).
92+
``` r
93+
source("https://mac.R-project.org/bin/install.R")
94+
install.libs("r-base-dev")
95+
```
9496
95-
2. Install GNU Fortran (gfortran) from the binary at
96-
<https://mac.r-project.org/tools/>.
97+
2. (Optional), install Pango for full Cairo support
9798
98-
3. Install XQuartz from the binary <https://www.xquartz.org/>.
99-
**Restart your computer** for XQuartz (and components that depend on
100-
it) to work!
99+
``` r
100+
install.libs("pango")
101+
```
101102
102-
4. Within R, use the helper R script to install commonly required
103-
prerequisites
103+
3. Check if you already have Subversion installed:
104104
105105
``` r
106-
source("https://mac.R-project.org/bin/install.R")
107-
install.libs("r-base-dev")
106+
system2("which", "svn")
108107
```
109108
110-
5. (Optional), within R, install Pango for full Cairo support
109+
This will print a path where Subversion is installed. If nothing is
110+
printed, install Subversion:
111111
112112
``` r
113-
install.libs("pango")
113+
install.libs("subversion", dep = FALSE)
114+
```
115+
116+
<details>
117+
<summary>
118+
119+
<i>Troubleshooting…</i>
120+
121+
</summary>
122+
123+
If this does not work, try installing Subversion via your preferred
124+
package manager, e.g. with Homebrew: <code>brew install svn</code>.
125+
126+
</details>
127+
128+
For the remaining instructions, run the code within Terminal.app
129+
130+
1. Install GNU Fortran (gfortran) from the binary at
131+
<https://mac.r-project.org/tools/>. This version is prepared for
132+
specifically for R and will be used in preference to any other
133+
version on your system.
134+
135+
2. From the terminal, install Xcode Command Line Tools
136+
137+
``` sh
138+
xcode-select --install
114139
```
115140
116-
6. Check if you have a current version of MacTeX installed:
141+
(If already installed, shows “xcode-select: error: command line
142+
tools are already installed”).
143+
144+
3. Check if you have a current version of MacTeX installed:
117145
118146
``` sh
119147
ls /usr/local/texlive
@@ -128,36 +156,23 @@ Open Terminal.app and follow these instructions:
128156
install MacTex from the binary at
129157
<https://tug.org/mactex/mactex-download.html>.
130158
131-
7. In the terminal, check if you already have Subversion installed:
159+
4. Check if you have XQuartz installed:
132160
133161
``` sh
134-
which svn
162+
mdls -name kMDItemVersion /Applications/Utilities/XQuartz.app
135163
```
136164
137-
This will show a path where Subversion is installed, or
138-
`svn not found`. If necessary, install Subversion from within R:
139-
140-
``` r
141-
install.libs("subversion", dep = FALSE)
142-
```
143-
144-
<details>
145-
<summary>
146-
147-
<i>Troubleshooting…</i>
148-
149-
</summary>
150-
151-
If this does not work, try installing via your preferred package
152-
manage, e.g. with Homebrew: <code>brew install svn</code>.
153-
154-
</details>
165+
This will show the version number or
166+
`could not find /Applications/Utilities/XQuartz.app`. If missing,
167+
install XQuartz from the binary at <https://www.xquartz.org/>.
168+
**Restart your computer** for XQuartz (and components that depend on
169+
it) to work!
155170
156-
8. (Recommended) If you are not already using a tool such as
171+
5. (Recommended) If you are not already using a tool such as
157172
[rig](https://github.com/r-lib/rig) to install and manage multiple R
158-
versions, install RSwitch from <https://rud.is/rswitch/>. These
159-
tools are not part of the R Project, but make it easy to switch R
160-
versions.
173+
versions, install RSwitch from <https://rud.is/rswitch/>. These are
174+
third-party tools, not part of the R Project, but are recommended
175+
here as they provide an easy way to switch R versions.
161176
162177
## Build R
163178

0 commit comments

Comments
 (0)