RStudio: wrapped or not wrapped? And what does "wrapped" even mean in the first place?

Hi.

I notice that if I search “rstudio” in Nix packages, I get two versions:

  • rstudio, and
  • rstudioWrapper

I tried looking up what the “wrapper” means, but I’m not sure where to find it.

What does “wrapper” mean? Where can I learn about it?

1 Like

tl;dr, use rstudio, you only need the wrapper if you want to install additional dependencies.

To understand it, though, you’ll need a bit of background (and it’s useful to understand if you’re going to use NixOS in anger):

NixOS, being based on nix, while a Linux distro, doesn’t follow a very important standard: the FHS standard.

The FHS standard is basically a set of rules for where applications should expect certain files to be. It dictates, for example, that executable binaries are stored in /bin (or /usr/bin, or /usr/local/bin), or that configuration files are stored in /etc.

nix basically exists as a project because some people realized over the years that this is a really freaking bad idea, as the mess of having multiple directories for it might suggest. It means that it’s practically impossible to have multiple different versions of a specific binary, library, configuration file, or even data files.

After all, you can’t have a /bin/python both be python versions 2 and 3, so if one application needs python 2 and one needs 3, you end up with applications fighting over which of their dependencies is the “canonical” version of that binary, and you end up being able to install one but not the other, or having to hack around a broken version requirement in one of them.

Traditionally, people solved this by banding together and producing Linux distributions that are very careful about not mixing different dependency versions, but with the exploding amount of software, this has become less and less feasible, and things like Docker and nix popped up to enable people to use mismatching software (as well as stuff like npm or tox for specific programming language ecosystems).

All of these projects are noncompliant with the FHS standard in some way (nix uses /nix/store paths, Docker creates virtual file systems, npm/tox just dump things into directories under $HOME).

A lot of background that will seem irrelevant so far. What does this have to do with “wrappers”?

Well, while on the packaging/ops end people have started ignoring the FHS standard, software is still written universally for that spec; there is no alternative, and people need to make their software work with FHS compliant systems.

This means that a lot of software is fundamentally incompatible with NixOS, and cannot work out of the box.

By that I mean; if R studio wants to open a shell, it needs to - instead of trying /bin/bash like it is supposed to according to the FHS standard - know exactly which path in /nix/store contains the bash binary it’s supposed to use.

To be able to make it work under NixOS when we have abandoned the FHS standard, we must give it that information somehow. That’s the job of the “wrapper” script - it sets some environment variables to change the paths R studio usually refers to. Specifically, it sets $PATH to contain a bunch of paths in /nix/store/*/bin, so that the things R needs to work are available (actually a slightly untrue example, it’s really about R packages/modules or whatever you call them, I’m just not very well versed in R so I can’t tell you exactly what paths/variables need to be set for it).

Typically this means you’re supposed to install the “wrapped” variant, e.g. don’t use firefox-unwrapped, because those versions are not compatible with non-FHS based systems. Those packages exist for special situations where you need to modify the package.

In the case of R studio, as the docs suggest, you only need to use the rstudioWrapper if you want to add additional packages, and you need to follow the documentation instructions to do so. Otherwise, just install rstudio. This is because the rstudio package is already wrapped for you - the “wrapper” just exists if you want to make your own wrapped version of rstudio.

11 Likes

Excellent summary, thanks!

Thanks for your reply, @TLATER

I assume most RStudio users will want to install packages from CRAN (or wherever). If you combine that with what you described regarding extra dependencies (or R packages), then I imagine most users should go for the rstudioWrapper.

If that is the case, then I have the question regarding how to automate the install of RStudio dependencies/packages within the configuration.nix, but I assume that is a question for another post.

For now, thank you so much for taking the time to explain this to me and all the future users who will be wondering about wrappers. Your post is the kind of posts that make Nix more accessible!