b-rodrigues / rix

Reproducible development environments for R with Nix
https://b-rodrigues.github.io/rix/
GNU General Public License v3.0
102 stars 11 forks source link

Targets Pipline: libxml2.so.2: cannot open shared object file: No such file or directory #171

Closed VtheRtech closed 3 weeks ago

VtheRtech commented 3 weeks ago

Hi Bruno!

I tested out the example script you gave in the docs and everything ran perfectly. However, when I reformatted the code and added it to my own pipeline there seemed to an unsatisfied dependencies seen below:

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/pretender/R/x86_64-pc-linux-gnu-library/4.3/igraph/libs/igraph.so':
  libxml2.so.2: cannot open shared object file: No such file or directory
Calls: loadNamespace ... asNamespace -> loadNamespace -> library.dynam -> dyn.load
Execution halted

Below is the snippet of env_build.R aka rix.R: Link to Git Repo

the closest solution I found was here

I'm unsure how to implement this fix in nix-shell. Any suggestion or help would be appreciated.

b-rodrigues commented 3 weeks ago

Hi!

what's happening is that you have a system level library of packages that interferes with the Nix one at runtime. {igraph} is a dependency of {targets} that only gets installed when you want to draw the DAG. Try installing igraph with rix as well and it should work.

Another fix could be to run rix::rix_init() within the projects folder to create an .Rprofile file that gets loaded when R gets started which removes the system library from libpath, but you'll have to install igraph anyways.

b-rodrigues commented 3 weeks ago

Also, it looks like you manually added these lines:

https://github.com/VtheRtech/trade-union-behavior-2020s/blob/3bae4130f8208452a2c70dc7176e2ee05a88d63e/default.nix#L32

I recommend you list all the deps in the rix.R file and then re-generate default.nix. List every package that is used, also the ones that you may not call on top of your scripts using library but with pkgs::fun(), for example {xfun}.

VtheRtech commented 3 weeks ago

other fix could be to run rix::rix_init() within the projects folder to create an .Rprofile file that gets loaded when R gets started which removes the system library from libpath, but you'll have to install igraph anyway

Thanks, Bruno this was the fix! Big fan of your blog & books btw can't wait to see your updated material.

b-rodrigues commented 3 weeks ago

thanks for reporting the issue, I'll have to document this!