Skip to content

Commit

Permalink
extras for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-baumann committed Feb 2, 2024
1 parent 053c324 commit fd62cec
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
8 changes: 5 additions & 3 deletions dev/0-dev_history.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,14 @@ rix(r_ver = "latest",
),
ide = "other",
project_path = "inst/extdata",
overwrite = TRUE)
overwrite = TRUE,
shell_hook = NULL)
```

Here's another, for testing purposes:

```{r, eval = FALSE}
rix(r_ver = "8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8",
rix(r_ver = "94b122adfc90316feaea838f29aa3f2e3de2b203",
r_pkgs = c("dplyr", "AER@1.2-8"),
system_pkgs = c("quarto"),
git_pkgs = list(
Expand All @@ -287,7 +288,8 @@ rix(r_ver = "8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8",
ide = "other",
project_path = "inst/extdata",
overwrite = TRUE,
print = TRUE)
print = TRUE,
shell_hook = NULL)
```


Expand Down
1 change: 0 additions & 1 deletion dev/a-getting_started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,3 @@ installed on your system.

- If you’re running either Linux or Windows, read the Linux or Windows vignette: `vignette("b1-setting-up-and-using-rix-on-linux-and-windows")`
- If you’re running macOS, read the macOS vignette: `vignette("b2-setting-up-and-using-rix-on-macos")`

24 changes: 23 additions & 1 deletion dev/b2-macos.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,26 @@ on macOS. When you try to generate an expression with `ide =
the Nix expression for RStudio.

We recommend you continue with the next vignette before tackling the more
advanced topics listed above: `vignette("c-using-rix-to-build-project-specific-environments")`.
advanced topics listed above: `vignette("c-using-rix-to-build-project-specific-environments")`.

## Why do we need all these special tweaks?

### Path of Nix installation not in `PATH`

When using RStudio Desktop on macOS, you typically launch it from the
Applications folder. However, RStudio currently lacks an option to start an
integrated R session via a shell startup on macOS (see this
[issue](https://github.com/rstudio/rstudio/issues/13341)
On RStudio for Linux flavors, `PATH` is properly inherited
in R sessions. As a result, key environmental variables for UNIX systems,
like PATH, are not be properly loaded from your default shell
(e.g., `zsh`, via `~/.zshrc`). Also, RStudio overwrites a `PATH` variable set
via `.Rprofile` or `.Renviron` with its own defaults, which makes it impossible
to find Nix and standard Nix tools like `nix-build`. It's worth noting that this
doesn't impact `rix::rix()`, which generates R expressions and doesn't require
a Nix installation. As a workaround, we have added mechanisms in `nix_build()`
and `with_nix()` that append the path of the Nix store to the `PATH` variable in
an active session automatically (via `Sys.setenv()`, when you use RStudio on
macOS. You don't have to do anything. We have you covered, and you get a
friendly message that informs you.
special side effect.
23 changes: 23 additions & 0 deletions vignettes/b2-setting-up-and-using-rix-on-macos.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,26 @@ on macOS. When you try to generate an expression with `ide =
We recommend you continue with the next vignette before tackling the more
advanced topics listed above: `vignette("c-using-rix-to-build-project-specific-environments")`.


## Why do we need all these special tweaks?

### Path of Nix installation not in `PATH`

When using RStudio Desktop on macOS, you typically launch it from the
Applications folder. However, RStudio currently lacks an option to start an
integrated R session via a shell startup on macOS (see this
[issue](https://github.com/rstudio/rstudio/issues/13341)
On RStudio for Linux flavors, `PATH` is properly inherited
in R sessions. As a result, key environmental variables for UNIX systems,
like PATH, are not be properly loaded from your default shell
(e.g., `zsh`, via `~/.zshrc`). Also, RStudio overwrites a `PATH` variable set
via `.Rprofile` or `.Renviron` with its own defaults, which makes it impossible
to find Nix and standard Nix tools like `nix-build`. It's worth noting that this
doesn't impact `rix::rix()`, which generates R expressions and doesn't require
a Nix installation. As a workaround, we have added mechanisms in `nix_build()`
and `with_nix()` that append the path of the Nix store to the `PATH` variable in
an active session automatically (via `Sys.setenv()`, when you use RStudio on
macOS. You don't have to do anything. We have you covered, and you get a
friendly message that informs you.
special side effect.

0 comments on commit fd62cec

Please sign in to comment.