NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.51k stars 13.69k forks source link

Need help with `rstudioWrapper` and `sf` #208070

Open CGenie opened 1 year ago

CGenie commented 1 year ago

Hello,

I have the following default.nix file:

with (import <nixpkgs> {});
let
  buildInputsEnv = [
    arpack
    libglvnd
    mesa.drivers
    postgresql
    gdal
    geos
    proj
    sqlite
  ];

  rPackagesEnv = [
    rPackages.class
    rPackages.ggplot2
    rPackages.KernSmooth
    rPackages.knitr
    rPackages.RPostgreSQL
    rPackages.s2
    rPackages.sf
    rPackages.units
  ];

  rEnv =
    pkgs.rWrapper.override {
      packages = rPackagesEnv ++ buildInputsEnv;
    };

  rstudioEnv =
    pkgs.rstudioWrapper.override {
      packages = rPackagesEnv ++ buildInputsEnv;
    };
in
stdenv.mkDerivation rec {
  name = "env";
  env = buildEnv {
    name = name;
    paths = buildInputs;
  };
  buildInputs = ([
    rEnv
    rstudioEnv
    #R
    #rstudio
  ] ++ buildInputsEnv);
}

Basically it creates environments for rWrapper and rstudioWrapper. However the R interpreters behave differently.

When I start R and type library("sf") I'm getting

Linking to GEOS 3.11.1, GDAL 3.6.1, PROJ 9.1.1; sf_use_s2() is TRUE

However when running rstudio and running the above I have

Error: package or namespace load failed for 'sf' in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/nix/store/vhjmjbhqqd749f664bny48bfl89bdb1v-r-sf-1.0-9/library/sf/libs/sf.so':
  libarpack.so.2: cannot open shared object file: No such file or directory

What could be the issue?

detroyejr commented 1 year ago

Hi, I wasn't able to reproduce this issue in my (relatively new) NixOS and WSL environments. Everything seems to have worked perfectly on both platforms. Any chance this is a Mac OS issue?

CGenie commented 1 year ago

I'm using Ubuntu 22.10.

detroyejr commented 1 year ago

Not sure if this improves things, but you might try nix-channel --update to see if the that helps.

And/or try a stable version of nixpkgs if you're not using that already. You can replace the import statement at the top with something like:

with (import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/06278c77b5d162e62df170fec307e83f1812d94b.tar.gz") {});

which should use the latest stable 22.11 channel (at the time of this post based on https://status.nixos.org/).